fix: cli missing macro define

This commit is contained in:
Zxilly 2023-12-25 20:33:58 +08:00
parent 7c23c9dba7
commit de2f9f4dec
6 changed files with 15 additions and 12 deletions

View File

@ -85,7 +85,7 @@ add_executable(ua2f
target_link_libraries(ua2f mnl netfilter_queue pthread nfnetlink)
if (UA2F_ENABLE_UCI)
add_compile_definitions(UA2F_USE_UCI=1)
add_compile_definitions(UA2F_ENABLE_UCI=1)
target_link_libraries(ua2f uci)
else ()
message(STATUS "UCI support is disabled.")

View File

@ -21,11 +21,16 @@ void try_print_info(const int argc, char *argv[]) {
#else
printf("Embed UA: not set\n");
#endif
#ifdef UA2F_ENABLE_UCI
if (config.use_custom_ua) {
printf("Config UA: %s\n", config.custom_ua);
} else {
printf("Config UA: not set\n");
}
#else
printf("UCI support disabled\n");
#endif
exit(0);
}

View File

@ -1,4 +1,4 @@
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#include <uci.h>
#include <string.h>
#include <syslog.h>
@ -40,4 +40,4 @@ void load_config() {
cleanup:
uci_free_context(ctx);
}
#endif //UA2F_USE_UCI
#endif

View File

@ -1,4 +1,4 @@
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#ifndef UA2F_CONFIG_H
#define UA2F_CONFIG_H
@ -14,4 +14,4 @@ void load_config();
extern struct ua2f_config config;
#endif //UA2F_CONFIG_H
#endif //UA2F_USE_UCI
#endif

View File

@ -5,10 +5,8 @@
#include "statistics.h"
#include "custom.h"
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#include "config.h"
#endif
#include <libnetfilter_queue/pktbuff.h>
@ -34,7 +32,7 @@ void init_handler() {
bool ua_set = false;
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
if (config.use_custom_ua) {
memset(replacement_user_agent_string, ' ', MAX_USER_AGENT_LENGTH);
strncpy(replacement_user_agent_string, config.custom_ua, strlen(config.custom_ua));

View File

@ -4,7 +4,7 @@
#include "cli.h"
#include "third/nfqueue-mnl.h"
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#include "config.h"
#endif
@ -26,11 +26,11 @@ void signal_handler(const int signum) {
int main(const int argc, char *argv[]) {
openlog("UA2F", LOG_PID, LOG_SYSLOG);
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
load_config();
#else
syslog(LOG_INFO, "uci support is disabled");
#endif //UA2F_USE_UCI
#endif
try_print_info(argc, argv);