From deb4ee52eb8ca69aa17a0f112e90bb0a6599da45 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Oct 2023 14:46:56 -0400 Subject: [PATCH] mmmm food --- include/insane_dns/constants.h | 3 +- include/insane_dns/util.h | 44 ++- libraries/BLT | 2 +- massif.out.11899 | 619 +++++++++++++++++++++++++++++++++ massif.out.12308 | 512 +++++++++++++++++++++++++++ src/main.cpp | 58 +-- 6 files changed, 1209 insertions(+), 29 deletions(-) create mode 100644 massif.out.11899 create mode 100644 massif.out.12308 diff --git a/include/insane_dns/constants.h b/include/insane_dns/constants.h index 19fd4a2..a242ea2 100644 --- a/include/insane_dns/constants.h +++ b/include/insane_dns/constants.h @@ -28,7 +28,8 @@ static constexpr size_t PACKET_BUFFER_SIZE = 65535; /* - * These structs are used in combination with templates to create a form of polymorphism which has significantly reduced the code reuse. + * These structs are used in combination with templates to create polymorphism between the UDP and TCP implementation. + * this design decision has significantly reduced the code reuse while not introducing any runtime overhead. * The data set within these structures are specific to the protocol they implement. UDP is exactly as specified in the RFC spec * TCP is what I observed from wireshark (+2 byte offset) */ diff --git a/include/insane_dns/util.h b/include/insane_dns/util.h index d016cbf..989054a 100644 --- a/include/insane_dns/util.h +++ b/include/insane_dns/util.h @@ -1,5 +1,5 @@ /* - * BLT Memory Util for parsing DNS packets / BLT + ASIO simple packet sender. + * BLT Memory Util for parsing DNS packets / BLT + ASIO simple packet sender / BLT Type Name Demangler. * This software is unlikely to become part of BLT main but is provided under the BLT license (GPL 3). * Copyright (C) 2023 Brett Terpstra, Et al * @@ -26,6 +26,13 @@ #include #include #include +#include + +#ifdef __GNUC__ + + #include + +#endif using asio::ip::udp; using asio::ip::tcp; @@ -128,6 +135,7 @@ namespace blt void sendUDPMessage(const std::string& host, const unsigned char* const& in, size_t in_size, blt::scoped_buffer& out, size_t& out_size) { + BLT_DEBUG("Sending UDP DNS request to '%s' of size %d", host.c_str(), in_size); asio::io_context io_context; udp::endpoint receiver_endpoint(asio::ip::address::from_string(host), 53); @@ -138,6 +146,7 @@ namespace blt udp::endpoint sender_endpoint; out_size = socket.receive_from(asio::buffer(out.data(), out.size()), sender_endpoint); + BLT_DEBUG("Received UDP DNS response from '%s' of size %d", host.c_str(), out_size); } /** @@ -151,6 +160,7 @@ namespace blt void sendTCPMessage(const std::string& host, const unsigned char* const& in, size_t in_size, blt::scoped_buffer& out, size_t& out_size) { + BLT_DEBUG("Sending TCP DNS request to '%s' of size %d", host.c_str(), in_size); asio::io_context io_context; tcp::resolver resolver(io_context); tcp::resolver::results_type endpoints = resolver.resolve(host, "53"); @@ -161,8 +171,40 @@ namespace blt asio::write(socket, asio::buffer(in, in_size)); out_size = socket.read_some(asio::buffer(out.data(), out.size())); + BLT_DEBUG("Received TCP dns response from '%s' of size %d", host.c_str(), out_size); } } + +#ifdef __GNUC__ + + /** + * Attempts to demangle the type name of the provided template type + * @tparam T + * @return + */ + template + static BLT_CPP20_CONSTEXPR inline std::string type_name() + { + int status; + std::string return_name = typeid(T).name(); + // only defined for GNU C++11? + char *demangled_name = abi::__cxa_demangle(return_name.c_str(), nullptr, nullptr, &status); + if (demangled_name == nullptr) + return return_name; + return_name = demangled_name; + std::free(demangled_name); + return return_name; + } + + template + static BLT_CPP20_CONSTEXPR inline std::string is_UDP_or_TCP(){ + std::string type = "UDP"; + if (blt::string::contains(blt::type_name(), "TCP")) + type = "TCP"; + return type; + } + +#endif } diff --git a/libraries/BLT b/libraries/BLT index 55c4974..1d8f9b4 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 55c497475e15b9a4ff0ac319c2997bd1869c4454 +Subproject commit 1d8f9b4bbdb84647c8a96b1ef87d262afd7021cb diff --git a/massif.out.11899 b/massif.out.11899 new file mode 100644 index 0000000..3f9ace2 --- /dev/null +++ b/massif.out.11899 @@ -0,0 +1,619 @@ +desc: (none) +cmd: ./cmake-build-release/insane_dns +time_unit: i +#----------- +snapshot=0 +#----------- +time=0 +mem_heap_B=0 +mem_heap_extra_B=0 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=1 +#----------- +time=1858253 +mem_heap_B=72704 +mem_heap_extra_B=8 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=2 +#----------- +time=1967477 +mem_heap_B=72721 +mem_heap_extra_B=31 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=3 +#----------- +time=2065395 +mem_heap_B=83254 +mem_heap_extra_B=426 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=4 +#----------- +time=2127401 +mem_heap_B=82839 +mem_heap_extra_B=385 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=5 +#----------- +time=2180342 +mem_heap_B=346399 +mem_heap_extra_B=521 +mem_stacks_B=0 +heap_tree=peak +n7: 346399 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6043 in 35 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=6 +#----------- +time=2228939 +mem_heap_B=346548 +mem_heap_extra_B=516 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=7 +#----------- +time=2302687 +mem_heap_B=348602 +mem_heap_extra_B=758 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=8 +#----------- +time=2402590 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=9 +#----------- +time=2483605 +mem_heap_B=347791 +mem_heap_extra_B=729 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=10 +#----------- +time=2565212 +mem_heap_B=347203 +mem_heap_extra_B=741 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=11 +#----------- +time=2621156 +mem_heap_B=347203 +mem_heap_extra_B=741 +mem_stacks_B=0 +heap_tree=detailed +n7: 347203 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6847 in 46 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=12 +#----------- +time=2686859 +mem_heap_B=346993 +mem_heap_extra_B=711 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=13 +#----------- +time=2791597 +mem_heap_B=347876 +mem_heap_extra_B=740 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=14 +#----------- +time=2843781 +mem_heap_B=347289 +mem_heap_extra_B=591 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=15 +#----------- +time=2921141 +mem_heap_B=348298 +mem_heap_extra_B=646 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=16 +#----------- +time=3030115 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=17 +#----------- +time=3097580 +mem_heap_B=346839 +mem_heap_extra_B=593 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=18 +#----------- +time=3142554 +mem_heap_B=347052 +mem_heap_extra_B=620 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=19 +#----------- +time=3219691 +mem_heap_B=346492 +mem_heap_extra_B=516 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=20 +#----------- +time=3279011 +mem_heap_B=347293 +mem_heap_extra_B=587 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=21 +#----------- +time=3354896 +mem_heap_B=348888 +mem_heap_extra_B=784 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=22 +#----------- +time=3432040 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=23 +#----------- +time=3491370 +mem_heap_B=347474 +mem_heap_extra_B=694 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=24 +#----------- +time=3566435 +mem_heap_B=347294 +mem_heap_extra_B=730 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=25 +#----------- +time=3626993 +mem_heap_B=346972 +mem_heap_extra_B=700 +mem_stacks_B=0 +heap_tree=detailed +n7: 346972 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6616 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=26 +#----------- +time=3716795 +mem_heap_B=346972 +mem_heap_extra_B=700 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=27 +#----------- +time=3761731 +mem_heap_B=346974 +mem_heap_extra_B=698 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=28 +#----------- +time=3836623 +mem_heap_B=347264 +mem_heap_extra_B=744 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=29 +#----------- +time=3926969 +mem_heap_B=346723 +mem_heap_extra_B=565 +mem_stacks_B=0 +heap_tree=detailed +n7: 346723 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6367 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=30 +#----------- +time=3972677 +mem_heap_B=348103 +mem_heap_extra_B=665 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=31 +#----------- +time=4056355 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=32 +#----------- +time=4147071 +mem_heap_B=347573 +mem_heap_extra_B=627 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=33 +#----------- +time=4192567 +mem_heap_B=347659 +mem_heap_extra_B=669 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=34 +#----------- +time=4260795 +mem_heap_B=346776 +mem_heap_extra_B=592 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=35 +#----------- +time=4306232 +mem_heap_B=347293 +mem_heap_extra_B=587 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=36 +#----------- +time=4374355 +mem_heap_B=348887 +mem_heap_extra_B=785 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=37 +#----------- +time=4455264 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=38 +#----------- +time=4523346 +mem_heap_B=346970 +mem_heap_extra_B=590 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=39 +#----------- +time=4591349 +mem_heap_B=347629 +mem_heap_extra_B=643 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=40 +#----------- +time=4636590 +mem_heap_B=346811 +mem_heap_extra_B=581 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=41 +#----------- +time=4727579 +mem_heap_B=347783 +mem_heap_extra_B=673 +mem_stacks_B=0 +heap_tree=detailed +n7: 347783 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 7427 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=42 +#----------- +time=4805586 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=43 +#----------- +time=4873480 +mem_heap_B=346929 +mem_heap_extra_B=583 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=44 +#----------- +time=4919047 +mem_heap_B=347515 +mem_heap_extra_B=597 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=45 +#----------- +time=4986981 +mem_heap_B=347195 +mem_heap_extra_B=613 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=46 +#----------- +time=5032678 +mem_heap_B=348375 +mem_heap_extra_B=777 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=47 +#----------- +time=5114347 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=48 +#----------- +time=5204963 +mem_heap_B=347542 +mem_heap_extra_B=602 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=49 +#----------- +time=5296131 +mem_heap_B=346751 +mem_heap_extra_B=577 +mem_stacks_B=0 +heap_tree=detailed +n7: 346751 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12315B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123177: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E23: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125E3F: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6395 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9F6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121189: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121370: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=50 +#----------- +time=5341085 +mem_heap_B=346939 +mem_heap_extra_B=605 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=51 +#----------- +time=5386034 +mem_heap_B=348215 +mem_heap_extra_B=785 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=52 +#----------- +time=5468799 +mem_heap_B=346383 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=53 +#----------- +time=5514187 +mem_heap_B=347599 +mem_heap_extra_B=609 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=54 +#----------- +time=5559331 +mem_heap_B=347542 +mem_heap_extra_B=602 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=55 +#----------- +time=5604884 +mem_heap_B=347629 +mem_heap_extra_B=643 +mem_stacks_B=0 +heap_tree=empty diff --git a/massif.out.12308 b/massif.out.12308 new file mode 100644 index 0000000..4417568 --- /dev/null +++ b/massif.out.12308 @@ -0,0 +1,512 @@ +desc: (none) +cmd: ./cmake-build-release/insane_dns +time_unit: i +#----------- +snapshot=0 +#----------- +time=0 +mem_heap_B=0 +mem_heap_extra_B=0 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=1 +#----------- +time=1858915 +mem_heap_B=72704 +mem_heap_extra_B=8 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=2 +#----------- +time=1968102 +mem_heap_B=72721 +mem_heap_extra_B=31 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=3 +#----------- +time=1991434 +mem_heap_B=84075 +mem_heap_extra_B=141 +mem_stacks_B=0 +heap_tree=detailed +n4: 84075 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 5512 0x13B5F7: blt::logging::tag_map::tag_map(std::initializer_list) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121247: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121440: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x13B9D6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121259: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121440: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n0: 347 in 6 places, all below massif's threshold (1.00%) +#----------- +snapshot=4 +#----------- +time=2022277 +mem_heap_B=81429 +mem_heap_extra_B=387 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=5 +#----------- +time=2066046 +mem_heap_B=83254 +mem_heap_extra_B=426 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=6 +#----------- +time=2097404 +mem_heap_B=82492 +mem_heap_extra_B=404 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=7 +#----------- +time=2128135 +mem_heap_B=82839 +mem_heap_extra_B=385 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=8 +#----------- +time=2164690 +mem_heap_B=83930 +mem_heap_extra_B=342 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=9 +#----------- +time=2185650 +mem_heap_B=347255 +mem_heap_extra_B=513 +mem_stacks_B=0 +heap_tree=peak +n7: 347255 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12322B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123247: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FBD: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FD9: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 6899 in 36 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9D6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121259: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121440: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=10 +#----------- +time=2217424 +mem_heap_B=347729 +mem_heap_extra_B=591 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=11 +#----------- +time=2238570 +mem_heap_B=347551 +mem_heap_extra_B=529 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=12 +#----------- +time=2273309 +mem_heap_B=348435 +mem_heap_extra_B=605 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=13 +#----------- +time=2296370 +mem_heap_B=348898 +mem_heap_extra_B=646 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=14 +#----------- +time=2336534 +mem_heap_B=347286 +mem_heap_extra_B=474 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=15 +#----------- +time=2402373 +mem_heap_B=347239 +mem_heap_extra_B=505 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=16 +#----------- +time=2431609 +mem_heap_B=347723 +mem_heap_extra_B=597 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=17 +#----------- +time=2460342 +mem_heap_B=348308 +mem_heap_extra_B=604 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=18 +#----------- +time=2503251 +mem_heap_B=347552 +mem_heap_extra_B=616 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=19 +#----------- +time=2531869 +mem_heap_B=348259 +mem_heap_extra_B=653 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=20 +#----------- +time=2559925 +mem_heap_B=347783 +mem_heap_extra_B=673 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=21 +#----------- +time=2599638 +mem_heap_B=348508 +mem_heap_extra_B=612 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=22 +#----------- +time=2623188 +mem_heap_B=347833 +mem_heap_extra_B=615 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=23 +#----------- +time=2652796 +mem_heap_B=348573 +mem_heap_extra_B=619 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=24 +#----------- +time=2675828 +mem_heap_B=348603 +mem_heap_extra_B=637 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=25 +#----------- +time=2700332 +mem_heap_B=349467 +mem_heap_extra_B=765 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=26 +#----------- +time=2737715 +mem_heap_B=348833 +mem_heap_extra_B=687 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=27 +#----------- +time=2806505 +mem_heap_B=347407 +mem_heap_extra_B=521 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=28 +#----------- +time=2828826 +mem_heap_B=347924 +mem_heap_extra_B=620 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=29 +#----------- +time=2858597 +mem_heap_B=348050 +mem_heap_extra_B=718 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=30 +#----------- +time=2880714 +mem_heap_B=348504 +mem_heap_extra_B=712 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=31 +#----------- +time=2917861 +mem_heap_B=348900 +mem_heap_extra_B=748 +mem_stacks_B=0 +heap_tree=detailed +n7: 348900 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12322B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123247: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FBD: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FD9: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 8544 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9D6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121259: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121440: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=32 +#----------- +time=2962541 +mem_heap_B=348485 +mem_heap_extra_B=763 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=33 +#----------- +time=2992631 +mem_heap_B=348959 +mem_heap_extra_B=769 +mem_stacks_B=0 +heap_tree=detailed +n7: 348959 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. + n1: 72704 0x49077B9: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 72704 0x4004ABD: call_init (dl-init.c:70) + n1: 72704 0x4004ABD: call_init (dl-init.c:26) + n1: 72704 0x4004BA3: _dl_init (dl-init.c:117) + n0: 72704 0x401AA5F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) + n1: 65535 0x12322B: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x123247: run_udp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FBD: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n1: 65535 0x125FD9: run_tcp_server() (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 65535 0x49364A2: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) + n1: 65535 0x4B25043: start_thread (pthread_create.c:442) + n0: 65535 0x4BA485F: clone (clone.S:100) + n0: 8603 in 50 places, all below massif's threshold (1.00%) + n1: 5512 0x13B9D6: std::__detail::_MakeUniq::__single_object std::make_unique(blt::logging::tag_map&&) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x121259: __static_initialization_and_destruction_0(int, int) [clone .constprop.0] (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) + n1: 5512 0x4AC32F5: call_init (libc-start.c:145) + n1: 5512 0x4AC32F5: __libc_start_main@@GLIBC_2.34 (libc-start.c:347) + n0: 5512 0x121440: (below main) (in /home/brett/Documents/code/c++/Insane_DNS/cmake-build-release/insane_dns) +#----------- +snapshot=34 +#----------- +time=3022333 +mem_heap_B=348515 +mem_heap_extra_B=765 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=35 +#----------- +time=3052343 +mem_heap_B=348485 +mem_heap_extra_B=763 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=36 +#----------- +time=3074669 +mem_heap_B=348447 +mem_heap_extra_B=761 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=37 +#----------- +time=3102477 +mem_heap_B=348046 +mem_heap_extra_B=730 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=38 +#----------- +time=3148713 +mem_heap_B=348228 +mem_heap_extra_B=764 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=39 +#----------- +time=3186244 +mem_heap_B=348198 +mem_heap_extra_B=778 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=40 +#----------- +time=3233405 +mem_heap_B=347703 +mem_heap_extra_B=601 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=41 +#----------- +time=3261461 +mem_heap_B=348569 +mem_heap_extra_B=639 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=42 +#----------- +time=3298648 +mem_heap_B=347767 +mem_heap_extra_B=601 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=43 +#----------- +time=3337191 +mem_heap_B=348547 +mem_heap_extra_B=661 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=44 +#----------- +time=3365261 +mem_heap_B=348094 +mem_heap_extra_B=546 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=45 +#----------- +time=3431516 +mem_heap_B=347407 +mem_heap_extra_B=521 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=46 +#----------- +time=3469646 +mem_heap_B=348563 +mem_heap_extra_B=629 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=47 +#----------- +time=3516029 +mem_heap_B=347680 +mem_heap_extra_B=624 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=48 +#----------- +time=3562998 +mem_heap_B=348678 +mem_heap_extra_B=690 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=49 +#----------- +time=3599873 +mem_heap_B=348011 +mem_heap_extra_B=701 +mem_stacks_B=0 +heap_tree=empty +#----------- +snapshot=50 +#----------- +time=3620865 +mem_heap_B=341878 +mem_heap_extra_B=482 +mem_stacks_B=0 +heap_tree=empty diff --git a/src/main.cpp b/src/main.cpp index 7650b17..e51e085 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,8 +13,9 @@ #include #include #include -#include // This might be necessary +#include #include +#include #include #include #include "ip.h" @@ -109,6 +110,11 @@ static constexpr bool REDIRECT_ADS = true; class send_buffer; +/** + * This data structure represents a DNS question. When constructed it will read the FULL domain as a single string, along with the QTYPE and QCLASS + * It is safe to read QDCOUNT questions by constructing this class. + * The question will be reconstructed by the send_buffer class. + */ class question { friend send_buffer; @@ -142,6 +148,11 @@ class question } }; +/** + * This data structure represents a DNS answer. When constructed it will read the FULL answer along with the associated data. It is therefore safe + * to read ANCOUNT by constructing a series of answers which read from the byte stream. This class cannot be copied but can be moved. + * The answer will be rebuilt by the send_buffer class for you. + */ class answer { friend send_buffer; @@ -152,7 +163,7 @@ class answer uint32_t TTL = 0; uint16_t RDLENGTH = 0; bool requires_reset = false; - unsigned char* RDATA = nullptr; + blt::scoped_buffer RDATA; public: explicit answer(const blt::byte_reader& reader) { @@ -161,10 +172,8 @@ class answer reader.to(CLASS); reader.to(TTL); reader.to(RDLENGTH); - RDATA = new unsigned char[RDLENGTH]; - reader.copy(RDATA, RDLENGTH); - - BLT_TRACE("%d, %d, %d, %d, %d", NAME, TYPE, CLASS, TTL, RDLENGTH); + RDATA = blt::scoped_buffer(RDLENGTH); + reader.copy(RDATA.data(), RDLENGTH); } [[nodiscard]] uint16_t type() const @@ -176,18 +185,17 @@ class answer { BLT_DEBUG("Substituting with replacement address '%s'", REPLACEMENT_IP().asString.c_str()); BLT_ASSERT(RDLENGTH == 4); - std::memcpy(RDATA, addr.octets, 4); + std::memcpy(RDATA.data(), addr.octets, 4); } inline void setARecord(const IPAddress& addr) { - BLT_DEBUG("Setting to A record"); + BLT_DEBUG("Setting answer to A record"); NAME = 0; NAME |= (0b11 << 14); requires_reset = true; - BLT_INFO(NAME); - delete[] RDATA; - RDATA = new unsigned char[4]; + BLT_TRACE(NAME); + RDATA = blt::scoped_buffer(4); RDLENGTH = 4; TYPE = 1; CLASS = 1; @@ -205,9 +213,10 @@ class answer } // rule of 5 - answer(const answer& answer) = delete; + // (there used to be a destructor) + answer(const answer& copy) = delete; - answer& operator=(const answer& answer) = delete; + answer& operator=(const answer& copy) = delete; answer(answer&& move) noexcept { @@ -216,8 +225,7 @@ class answer CLASS = move.CLASS; TTL = move.TTL; RDLENGTH = move.RDLENGTH; - RDATA = move.RDATA; - move.RDATA = nullptr; + RDATA = std::move(move.RDATA); } answer& operator=(answer&& move) noexcept @@ -228,15 +236,12 @@ class answer CLASS = move.CLASS; TTL = move.TTL; RDLENGTH = move.RDLENGTH; - RDATA = move.RDATA; - move.RDATA = nullptr; + RDATA = std::move(move.RDATA); return *this; } - ~answer() - { - delete[] RDATA; - } + // there used to be a destructor + ~answer() = default; }; class send_buffer @@ -267,7 +272,7 @@ class send_buffer write(t.CLASS); write(t.TTL); write(t.RDLENGTH); - std::memcpy(&internal_data[write_index], t.RDATA, t.RDLENGTH); + std::memcpy(&internal_data[write_index], t.RDATA.data(), t.RDLENGTH); write_index += t.RDLENGTH; } else if constexpr (std::is_same_v) { @@ -341,7 +346,7 @@ request_info handle_forward_request(MESSENGER messenger, const INFO& info, const uint16_t questions; // yes I made this part of my library just for this :3 blt::mem::fromBytes(&input_recv_buffer[info.QUESTIONS_BEGIN], questions); // i hate little endian - BLT_INFO("Bytes received: %d with %d questions", bytes, questions); + BLT_INFO("(%s) Bytes received: %d with %d questions", blt::is_UDP_or_TCP().c_str(), bytes, questions); // forward to google. size_t out_bytes; @@ -359,7 +364,8 @@ void handle_response(const INFO& info, send_buffer& return_send_buffer, request_ { blt::byte_reader reader(forward_recv_buffer.data(), forward_recv_buffer.size(), info.HEADER_END); - BLT_INFO("Bytes answered: %d with %d answers", rq_info.number_of_bytes, rq_info.number_of_answers); + auto TYPE_STR = blt::is_UDP_or_TCP(); + BLT_INFO("(%s) Bytes answered: %d with %d answers", TYPE_STR.c_str(), rq_info.number_of_bytes, rq_info.number_of_answers); // no one actually does multiple questions. trying to do it in dig is not easy // and the standard isn't really designed for this (how do we handle if one question errors but the other doesn't? there is only @@ -372,7 +378,7 @@ void handle_response(const INFO& info, send_buffer& return_send_buffer, request_ answers.push_back(std::move(a)); } - BLT_INFO("DOMAIN: %s", q().c_str()); + BLT_INFO("(%s) DOMAIN: %s", TYPE_STR.c_str(), q().c_str()); if (STRICT_MATCHING && BLT_CONTAINS(DISALLOWED_DOMAINS, q())) process_answers(answers); else if (!STRICT_MATCHING) @@ -388,7 +394,7 @@ void handle_response(const INFO& info, send_buffer& return_send_buffer, request_ return_send_buffer.write(q); for (const answer& a : answers) { - BLT_TRACE("Writing answer with type of %d", a.type()); + BLT_TRACE("(%s) Writing answer with type of %d", TYPE_STR.c_str(), a.type()); a.reset(question_offset); return_send_buffer.write(a); }