From 22668406df5b95772d0be15507b768dfe31f5bbf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 21 Jul 2020 06:09:43 +0200 Subject: [PATCH] Add new extended version CLI argument: "pihole -vv" listing also the versions of dnsmasq and LUA (if embedded) Signed-off-by: DL6ER --- src/CMakeLists.txt | 2 ++ src/args.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 557ed081..3c948ee3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,6 +165,7 @@ if(STATIC STREQUAL "true") target_link_libraries(pihole-FTL -static-libgcc -static -static-pie) endif() target_compile_options(pihole-FTL PRIVATE ${EXTRAWARN}) +target_compile_definitions(pihole-FTL PRIVATE DNSMASQ_VERSION=\"${DNSMASQ_VERSION}\") target_include_directories(pihole-FTL PRIVATE ${PROJECT_SOURCE_DIR}/src) add_dependencies(pihole-FTL gen_version) @@ -184,6 +185,7 @@ target_link_libraries(pihole-FTL rt Threads::Threads ${HOGWEED} ${GMP} ${NETTLE} # for LUASCRIPT support we add liblua, libdl (lookforfunc) and libm # Only liblua is linked statically as linking libm and libdl statically is discouraged if(FTL_LUA STREQUAL "true") + target_compile_definitions(pihole-FTL PRIVATE FTL_LUA) find_library(LUA liblua${CMAKE_STATIC_LIBRARY_SUFFIX}) find_library(DL dl) find_library(MATH m) diff --git a/src/args.c b/src/args.c index c7bd024a..8ee64ad7 100644 --- a/src/args.c +++ b/src/args.c @@ -8,6 +8,11 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ +// DNSMASQ COPYRIGHT +#define FTLDNS +#include "dnsmasq/dnsmasq.h" +#undef __USE_XOPEN + #include "FTL.h" #include "args.h" #include "version.h" @@ -17,6 +22,11 @@ // global variable killed #include "signals.h" +// LUA version +#ifdef FTL_LUA +#include +#endif + static bool debug = false; bool daemonmode = true; int argc_dnsmasq = 0; @@ -129,6 +139,18 @@ void parse_args(int argc, char* argv[]) exit(EXIT_SUCCESS); } + if(strcmp(argv[i], "-vv") == 0) // Extended version + { + printf("Pi-hole FTL: %s\n", get_FTL_version()); + printf("dnsmasq: "DNSMASQ_VERSION" "COPYRIGHT"\n"); +#ifdef FTL_LUA + printf("LUA: "LUA_COPYRIGHT"\n"); +#else + printf("LUA: --- (no LUA embedded)\n"); +#endif + exit(EXIT_SUCCESS); + } + if(strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "tag") == 0) { @@ -163,6 +185,7 @@ void parse_args(int argc, char* argv[]) printf("\t test Don't start pihole-FTL but\n"); printf("\t instead quit immediately\n"); printf("\t-v, version Return version\n"); + printf("\t-vv Return extended version\n"); printf("\t-t, tag Return git tag\n"); printf("\t-b, branch Return git branch\n"); printf("\t-f, no-daemon Don't go into daemon mode\n");