Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dooked/include/cli_preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "dns/dns_resolver.hpp"
#include "utils/io_utils.hpp"
#include <ctime>
#include <optional>
#include <thread>

// maximum sockets to open regardless of the number of threads
Expand All @@ -24,7 +26,10 @@ struct cli_args_t {
int post_http_request{};
int thread_count{};
int content_length{-1};
int last_seen_days{-1};
std::string last_seen_date{};
bool include_date{false};
bool first_seen{false};
};

struct runtime_args_t {
Expand All @@ -36,6 +41,9 @@ struct runtime_args_t {
http_process_e http_request_time_{};
int thread_count{};
int content_length{-1};
int last_seen_days{-1};
std::optional<std::time_t> last_seen_cutoff{};
bool first_seen{false};
};

void run_program(cli_args_t const &cli_args);
Expand Down
15 changes: 15 additions & 0 deletions dooked/include/utils/io_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ void trim(std::string &);
struct json_data_t {
std::string domain_name{};
std::string rdata{};
std::string first_seen{};
std::string last_seen{};
int ttl{};
int http_code{};
int content_length{};
int seen_count{};
dns_record_type_e type{};

static json_data_t serialize(std::string const &d, int const len,
Expand All @@ -40,6 +43,18 @@ struct json_data_t {
dns_str_to_record_type(json_object["type"].get<json::string_t>());
data.rdata = json_object["info"].get<json::string_t>();
data.ttl = json_object["ttl"].get<json::number_integer_t>();
if (auto iter = json_object.find("first-seen");
iter != json_object.end() && iter->second.is_string()) {
data.first_seen = iter->second.get<json::string_t>();
}
if (auto iter = json_object.find("last-seen");
iter != json_object.end() && iter->second.is_string()) {
data.last_seen = iter->second.get<json::string_t>();
}
if (auto iter = json_object.find("seen");
iter != json_object.end() && iter->second.is_number_integer()) {
data.seen_count = iter->second.get<json::number_integer_t>();
}
data.content_length = len;
data.http_code = http_code;
return data;
Expand Down
3 changes: 3 additions & 0 deletions dooked/include/utils/probe_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ struct probe_result_t {
std::string rdata{};
dns_record_type_e type{}; // RR TYPE (2 octets)
std::uint32_t ttl{}; // time to live(4 octets)
std::string first_seen{};
std::string last_seen{};
int seen_count{};

friend bool operator==(probe_result_t const &a, probe_result_t const &b) {
return case_insensitive_compare(a.rdata, b.rdata) && (a.type == b.type);
Expand Down
Loading