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).
pull/48/head
Soner Tari 3 years ago
parent 9c8e56d5df
commit e993ccdb5d

@ -49,6 +49,7 @@
#define STRORNONE(x) (((x)&&*(x))?(x):"") #define STRORNONE(x) (((x)&&*(x))?(x):"")
enum filter_action { enum filter_action {
FILTER_ACTION_IGNORE = -1,
FILTER_ACTION_NONE = 0, FILTER_ACTION_NONE = 0,
FILTER_ACTION_DIVERT, FILTER_ACTION_DIVERT,
FILTER_ACTION_SPLIT, FILTER_ACTION_SPLIT,

@ -1977,18 +1977,15 @@ enum filter_action
pxyconn_set_filter_action(pxy_conn_ctx_t *ctx, filter_site_t *site) pxyconn_set_filter_action(pxy_conn_ctx_t *ctx, filter_site_t *site)
{ {
if (site->divert) { if (site->divert) {
if (!ctx->divert) { log_err_level_printf(LOG_INFO, "Site filter divert action for %s\n", site->site);
log_err_level_printf(LOG_INFO, "Site filter divert action for %s\n", site->site); return FILTER_ACTION_DIVERT;
return FILTER_ACTION_DIVERT;
}
} }
else if (site->split) { else if (site->split) {
if (ctx->divert) { log_err_level_printf(LOG_INFO, "Site filter split action for %s\n", site->site);
log_err_level_printf(LOG_INFO, "Site filter split action for %s\n", site->site); return FILTER_ACTION_SPLIT;
return FILTER_ACTION_SPLIT;
}
} }
else if (site->pass) { else if (site->pass) {
// Ignore pass action if already in passthrough mode
if (!ctx->pass) { if (!ctx->pass) {
log_err_level_printf(LOG_INFO, "Site filter pass action for %s\n", site->site); log_err_level_printf(LOG_INFO, "Site filter pass action for %s\n", site->site);
return FILTER_ACTION_PASS; 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); log_err_level_printf(LOG_INFO, "Site filter block action for %s\n", site->site);
return FILTER_ACTION_BLOCK; return FILTER_ACTION_BLOCK;
} }
return FILTER_ACTION_NONE; return FILTER_ACTION_IGNORE;
} }
enum filter_action enum filter_action

Loading…
Cancel
Save