From 739c24cdf3575c406da02af59e1e9fdf006882cf Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 2 Feb 2026 13:57:40 +0300 Subject: [PATCH] nfqws2: process --filter-l3 as a list in templates --- docs/manual.en.md | 2 +- docs/manual.md | 2 +- nfq2/nfqws.c | 10 +++++++--- nfq2/params.c | 15 +++++++++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/manual.en.md b/docs/manual.en.md index 99be43a..733a6c4 100644 --- a/docs/manual.en.md +++ b/docs/manual.en.md @@ -800,7 +800,7 @@ When there are many complex and repetitive strategies or groups of the same para A template is also a profile but it doesn't go to the working profile list but to a separate list of templates. The profile becomes a template by setting the `--template = ` parameter. It can then be imported (`--import = `) into another profile or template. -Simple parameters - number, string, bool, `--filter-l3` - are imported only if they were specified in the imported template. When you import a template into a template in the destination template, they are also considered specified. +Simple parameters - number, string, bool - are imported only if they were specified in the imported template. When you import a template into a template in the destination template, they are also considered specified. List parameters are added to the end of the corresponding list. Such parameters are anything that can take a list of values. For example, hostlists or `--filter-tcp`. The template number and name are not copied. diff --git a/docs/manual.md b/docs/manual.md index ff7d235..b044269 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -865,7 +865,7 @@ icmp автоматически подразумевает и icmpv6 - они о Шаблон - это такой же профиль, только он не идет в работу, а попадает в отдельный список шаблонов. Шаблоном профиль становится через задание параметра `--template=`. Далее он может быть импортирован (`--import=`) в другой профиль или другой шаблон. -Простые параметры - число, строка, bool, `--filter-l3` - импортируются только, если они были заданы в импортируемом шаблоне. При иморте шаблона в шаблон в шаблоне назначения они так же считаются заданными. +Простые параметры - число, строка, bool - импортируются только, если они были заданы в импортируемом шаблоне. При иморте шаблона в шаблон в шаблоне назначения они так же считаются заданными. Списочные параметры добавляются в конец списка. Такими параметрами является все, что может принимать список значений. Например, хостлисты или `--filter-tcp`. Номер и имя шаблона не копируются. Директив `--import` может быть сколько угодно в любом месте. Предыдущие простые заданные параметры затираются новыми импортированными или заданными в текущем профиле. diff --git a/nfq2/nfqws.c b/nfq2/nfqws.c index da60cdf..d9952ff 100644 --- a/nfq2/nfqws.c +++ b/nfq2/nfqws.c @@ -1222,7 +1222,8 @@ static bool wf_make_l3(char *opt, bool *ipv4, bool *ipv6) { char *e, *p, c; - for (p = opt, *ipv4 = *ipv6 = false; p; ) + // do not overwrite ipv4 and ipv6 old values. OR instead - simulate adding to the list + for (p = opt; p; ) { if ((e = strchr(p, ','))) { @@ -1343,8 +1344,11 @@ static void LuaDesyncDebug(struct desync_profile *dp, const char *entity) } } -static bool deny_proto_filters(struct desync_profile *dp) +static bool filter_defaults(struct desync_profile *dp) { + // enable both ipv4 and ipv6 if not specified + if (!dp->b_filter_l3) dp->filter_ipv4 = dp->filter_ipv6 = true; + // if any filter is set - deny all unset if (!LIST_EMPTY(&dp->pf_tcp) || !LIST_EMPTY(&dp->pf_udp) || !LIST_EMPTY(&dp->icf) || !LIST_EMPTY(&dp->ipf)) { @@ -2931,7 +2935,7 @@ int main(int argc, char **argv) DLOG_ERR("could not make '%s' accessible. auto hostlist file may not be writable after privilege drop\n", dp->hostlist_auto->filename); } - if (!deny_proto_filters(dp)) exit_clean(1); + if (!filter_defaults(dp)) exit_clean(1); LuaDesyncDebug(dp,"profile"); } LIST_FOREACH(dpl, ¶ms.desync_templates, next) diff --git a/nfq2/params.c b/nfq2/params.c index 439918b..fae9255 100644 --- a/nfq2/params.c +++ b/nfq2/params.c @@ -356,7 +356,6 @@ void dp_init(struct desync_profile *dp) dp->hostlist_auto_incoming_maxseq = HOSTLIST_AUTO_INCOMING_MAXSEQ; dp->hostlist_auto_udp_out = HOSTLIST_AUTO_UDP_OUT; dp->hostlist_auto_udp_in = HOSTLIST_AUTO_UDP_IN; - dp->filter_ipv4 = dp->filter_ipv6 = true; } static void dp_clear_dynamic(struct desync_profile *dp) { @@ -428,9 +427,17 @@ bool dp_copy(struct desync_profile *to, const struct desync_profile *from) DP_COPY_SIMPLE(filter_l7) if (from->b_filter_l3) { - to->filter_ipv4 = from->filter_ipv4; - to->filter_ipv6 = from->filter_ipv6; - to->b_filter_l3 = true; + if (to->b_filter_l3) + { + to->filter_ipv4 |= from->filter_ipv4; + to->filter_ipv6 |= from->filter_ipv6; + } + else + { + to->filter_ipv4 = from->filter_ipv4; + to->filter_ipv6 = from->filter_ipv6; + to->b_filter_l3 = true; + } } // copy dynamic structures