Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00

nfqws2: process --filter-l3 as a list in templates

This commit is contained in:
bol-van
2026-02-02 13:57:40 +03:00
parent 5c97563698
commit 739c24cdf3
4 changed files with 20 additions and 9 deletions

View File

@@ -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. 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 = <name>` parameter. The profile becomes a template by setting the `--template = <name>` parameter.
It can then be imported (`--import = <name>`) into another profile or template. It can then be imported (`--import = <name>`) 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`. 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. The template number and name are not copied.

View File

@@ -865,7 +865,7 @@ icmp автоматически подразумевает и icmpv6 - они о
Шаблон - это такой же профиль, только он не идет в работу, а попадает в отдельный список шаблонов. Шаблон - это такой же профиль, только он не идет в работу, а попадает в отдельный список шаблонов.
Шаблоном профиль становится через задание параметра `--template=<name>`. Шаблоном профиль становится через задание параметра `--template=<name>`.
Далее он может быть импортирован (`--import=<name>`) в другой профиль или другой шаблон. Далее он может быть импортирован (`--import=<name>`) в другой профиль или другой шаблон.
Простые параметры - число, строка, bool, `--filter-l3` - импортируются только, если они были заданы в импортируемом шаблоне. При иморте шаблона в шаблон в шаблоне назначения они так же считаются заданными. Простые параметры - число, строка, bool - импортируются только, если они были заданы в импортируемом шаблоне. При иморте шаблона в шаблон в шаблоне назначения они так же считаются заданными.
Списочные параметры добавляются в конец списка. Такими параметрами является все, что может принимать список значений. Например, хостлисты или `--filter-tcp`. Списочные параметры добавляются в конец списка. Такими параметрами является все, что может принимать список значений. Например, хостлисты или `--filter-tcp`.
Номер и имя шаблона не копируются. Номер и имя шаблона не копируются.
Директив `--import` может быть сколько угодно в любом месте. Предыдущие простые заданные параметры затираются новыми импортированными или заданными в текущем профиле. Директив `--import` может быть сколько угодно в любом месте. Предыдущие простые заданные параметры затираются новыми импортированными или заданными в текущем профиле.

View File

@@ -1222,7 +1222,8 @@ static bool wf_make_l3(char *opt, bool *ipv4, bool *ipv6)
{ {
char *e, *p, c; 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, ','))) 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 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)) 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); 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"); LuaDesyncDebug(dp,"profile");
} }
LIST_FOREACH(dpl, &params.desync_templates, next) LIST_FOREACH(dpl, &params.desync_templates, next)

View File

@@ -356,7 +356,6 @@ void dp_init(struct desync_profile *dp)
dp->hostlist_auto_incoming_maxseq = HOSTLIST_AUTO_INCOMING_MAXSEQ; dp->hostlist_auto_incoming_maxseq = HOSTLIST_AUTO_INCOMING_MAXSEQ;
dp->hostlist_auto_udp_out = HOSTLIST_AUTO_UDP_OUT; dp->hostlist_auto_udp_out = HOSTLIST_AUTO_UDP_OUT;
dp->hostlist_auto_udp_in = HOSTLIST_AUTO_UDP_IN; 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) 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) DP_COPY_SIMPLE(filter_l7)
if (from->b_filter_l3) if (from->b_filter_l3)
{ {
to->filter_ipv4 = from->filter_ipv4; if (to->b_filter_l3)
to->filter_ipv6 = from->filter_ipv6; {
to->b_filter_l3 = true; 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 // copy dynamic structures