From a93aa69756ac1a13ace8ca9fb765794d42873b71 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 5 Sep 2022 16:04:50 +0200 Subject: [PATCH] make it possible to run without a configuration file --- CMakeLists.txt | 17 ++++++----------- README.md | 7 +++++++ make-built-in-config.sh | 11 +++++++++++ teller.cc | 5 +++-- 4 files changed, 27 insertions(+), 13 deletions(-) create mode 100755 make-built-in-config.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index b284863..670311f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,17 +9,9 @@ set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use") set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) -#add_library(support STATIC ext/powerblog/h2o-pp.cc -# ext/powerblog/ext/simplesocket/swrappers.cc -# ext/powerblog/ext/simplesocket/comboaddress.cc -# ext/powerblog/ext/simplesocket/sclasses.cc -# ext/fmt-7.1.3/src/format.cc) +add_custom_target(Work ALL DEPENDS configs.hh) - -#target_include_directories(support PUBLIC ext/powerblog/ext/simplesocket ext/powerblog/ext ext/fmt-7.1.3/include/) -#target_link_libraries(support PUBLIC -lh2o-evloop -lssl -lcrypto Threads::Threads) - add_executable(teller teller.cc ext/lpm.c) target_link_libraries(teller -lpcaudio -lpthread) @@ -29,6 +21,9 @@ target_link_libraries(testrunner -lpcaudio) enable_testing() add_test(testname testrunner) +add_custom_command( + OUTPUT configs.hh + COMMAND ./make-built-in-config.sh + DEPENDS teller.conf trackers.conf +) -enable_testing() -add_test(testname testrunner) diff --git a/README.md b/README.md index dbd7d5d..b4c3e5c 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,13 @@ Demo video [in this tweet](https://twitter.com/bert_hu_bert/status/1561466204602 [Blog post with more videos](https://berthub.eu/articles/posts/tracker-beeper/) +## Installing on OSX: +``` +brew tap robertjakub/teller +brew install --HEAD googerteller +sudo tcpdump -nql | teller +``` + ## How to compile This will currently only work on Unix derived systems (like Linux, OSX and FreeBSD). diff --git a/make-built-in-config.sh b/make-built-in-config.sh new file mode 100755 index 0000000..d395aee --- /dev/null +++ b/make-built-in-config.sh @@ -0,0 +1,11 @@ +#!/bin/sh +( +echo \#pragma once +echo 'constexpr char tellertoml[]=R"(' +cat teller.conf +echo ')";' + +echo 'constexpr char trackerstoml[]=R"(' +cat trackers.conf +echo ')";' +) > configs.hh \ No newline at end of file diff --git a/teller.cc b/teller.cc index 2f5a082..0d03ab2 100644 --- a/teller.cc +++ b/teller.cc @@ -7,6 +7,7 @@ #include #include "ext/toml.hpp" #include "lpmwrapper.hh" +#include "configs.hh" using namespace std; @@ -73,12 +74,12 @@ int main(int argc, char** argv) { trackertbl = toml::parse_file("trackers.conf"); conftbl = toml::parse_file("teller.conf"); - // std::cout << tbl << "\n"; } catch (const toml::parse_error& err) { std::cerr << "Parsing failed:\n" << err << "\n"; - return 1; + trackertbl = toml::parse(trackerstoml); + conftbl = toml::parse(tellertoml); } map trackerdb;