v1.1.4 : Output more human readable and no more useless alias for namespace
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
namespace etix {
|
namespace etix {
|
||||||
namespace cameradar {
|
namespace cameradar {
|
||||||
|
|
||||||
|
static const std::string default_result_file_path = "/tmp/shared/result.json";
|
||||||
|
|
||||||
class print : public etix::cameradar::cameradar_task {
|
class print : public etix::cameradar::cameradar_task {
|
||||||
const configuration& conf;
|
const configuration& conf;
|
||||||
std::shared_ptr<cache_manager> cache;
|
std::shared_ptr<cache_manager> cache;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
#include <iostream> // iostream
|
#include <iostream> // iostream
|
||||||
#include <opt_parse.h> // parsing opt
|
#include <opt_parse.h> // parsing opt
|
||||||
|
|
||||||
namespace cmrdr = etix::cameradar;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
print_version() {
|
print_version() {
|
||||||
std::cout << "Cameradar version " << CAMERADAR_VERSION << std::endl;
|
std::cout << "Cameradar version " << CAMERADAR_VERSION << std::endl;
|
||||||
@@ -108,7 +106,7 @@ main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to load the configuration
|
// Try to load the configuration
|
||||||
auto conf = cmrdr::load(args);
|
auto conf = etix::cameradar::load(args);
|
||||||
if (not conf.first) { return EXIT_FAILURE; }
|
if (not conf.first) { return EXIT_FAILURE; }
|
||||||
|
|
||||||
LOG_INFO_("Configuration successfully loaded", "main");
|
LOG_INFO_("Configuration successfully loaded", "main");
|
||||||
|
|||||||
@@ -21,24 +21,28 @@ namespace cameradar {
|
|||||||
// Uses the subnets specified in the conf file to launch nmap
|
// Uses the subnets specified in the conf file to launch nmap
|
||||||
bool
|
bool
|
||||||
print::run() const {
|
print::run() const {
|
||||||
|
bool first = true;
|
||||||
std::vector<stream_model> results = (*cache)->get_valid_streams();
|
std::vector<stream_model> results = (*cache)->get_valid_streams();
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
bool first = true;
|
|
||||||
file.open("/tmp/shared/result.json");
|
file.open(default_result_file_path);
|
||||||
|
if (file.fail()) {
|
||||||
|
LOG_ERR_("Result file could not be opened : " + default_result_file_path, "print");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
file << "[\n";
|
file << "[\n";
|
||||||
for (const auto& stream : results) {
|
for (const auto& stream : results) {
|
||||||
LOG_INFO_("Found a valid RTSP Stream and generated a thumbnail at : " +
|
file << deserialize(stream).toStyledString();
|
||||||
stream.thumbnail_path,
|
|
||||||
"print");
|
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
first = false;
|
first = false;
|
||||||
else
|
else
|
||||||
file << ",";
|
file << ",";
|
||||||
file << deserialize(stream).toStyledString();
|
|
||||||
LOG_INFO_("Generated JSON Result : " + deserialize(stream).toStyledString(), "print");
|
LOG_INFO_("Generated JSON Result : " + deserialize(stream).toStyledString(), "print");
|
||||||
}
|
}
|
||||||
file << "\n]";
|
file << "]";
|
||||||
file.close();
|
file.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user