From e993ccdb5d6fe09e02d985fc7c88d2fa1b7f8e94 Mon Sep 17 00:00:00 2001 From: Soner Tari Date: Tue, 14 Sep 2021 15:45:19 +0300 Subject: [PATCH] Add FILTER_ACTION_IGNORE action Differentiate filter action for site match from no site match. The search should stop if a match is found, even if the action does not change anything in effect (divert/split action in divert/split mode, respectively) or the action is ignored (pass action in passthrough mode). --- src/opts.h | 1 + src/pxyconn.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/opts.h b/src/opts.h index bf78e1d..81329bb 100644 --- a/src/opts.h +++ b/src/opts.h @@ -49,6 +49,7 @@ #define STRORNONE(x) (((x)&&*(x))?(x):"") enum filter_action { + FILTER_ACTION_IGNORE = -1, FILTER_ACTION_NONE = 0, FILTER_ACTION_DIVERT, FILTER_ACTION_SPLIT, diff --git a/src/pxyconn.c b/src/pxyconn.c index e709141..ac5adf8 100644 --- a/src/pxyconn.c +++ b/src/pxyconn.c @@ -1977,18 +1977,15 @@ enum filter_action pxyconn_set_filter_action(pxy_conn_ctx_t *ctx, filter_site_t *site) { if (site->divert) { - if (!ctx->divert) { - log_err_level_printf(LOG_INFO, "Site filter divert action for %s\n", site->site); - return FILTER_ACTION_DIVERT; - } + log_err_level_printf(LOG_INFO, "Site filter divert action for %s\n", site->site); + return FILTER_ACTION_DIVERT; } else if (site->split) { - if (ctx->divert) { - log_err_level_printf(LOG_INFO, "Site filter split action for %s\n", site->site); - return FILTER_ACTION_SPLIT; - } + log_err_level_printf(LOG_INFO, "Site filter split action for %s\n", site->site); + return FILTER_ACTION_SPLIT; } else if (site->pass) { + // Ignore pass action if already in passthrough mode if (!ctx->pass) { log_err_level_printf(LOG_INFO, "Site filter pass action for %s\n", site->site); return FILTER_ACTION_PASS; @@ -1998,7 +1995,7 @@ pxyconn_set_filter_action(pxy_conn_ctx_t *ctx, filter_site_t *site) log_err_level_printf(LOG_INFO, "Site filter block action for %s\n", site->site); return FILTER_ACTION_BLOCK; } - return FILTER_ACTION_NONE; + return FILTER_ACTION_IGNORE; } enum filter_action