MINOR: sample: converter for frontend existence check

Introduced a new sample converter using keyword "fe_exists" checking if
a frontend with a given name exists.
This commit is contained in:
Pierre Cheynier 2026-04-17 07:37:14 +00:00 committed by William Lallemand
parent 0be6c0076d
commit 85c3f3c1fd
2 changed files with 28 additions and 0 deletions

View File

@ -21018,6 +21018,7 @@ eth.proto binary integer
eth.src binary binary
eth.vlan binary integer
even integer boolean
fe_exists string boolean
field(index,delimiters[,count]) string string
fix_is_valid binary boolean
fix_tag_value(tag) binary binary
@ -21548,6 +21549,15 @@ field(<index>,<delimiters>[,<count>])
str(f1_f2_f3__f5),field(-2,_,3) # f2_f3_
str(f1_f2_f3__f5),field(-3,_,0) # f1_f2_f3
fe_exists
Takes a frontend name as input value and returns a boolean TRUE if the said
frontend with that name exists in the current configuration, otherwise returns
FALSE. Can be used in places where checking the existence of a frontend from a
dynamic name is valuable, like map lookups or answering to an external check.
Example :
http-request deny unless { var(txn.fe_name),fe_exists }
fix_is_valid
Parses a binary payload and performs sanity checks regarding FIX (Financial
Information eXchange):

View File

@ -326,6 +326,16 @@ smp_fetch_fe_tarpit_timeout(const struct arg *args, struct sample *smp, const ch
return 1;
}
static int
sample_conv_fe_exists(const struct arg *args, struct sample *smp, void *private)
{
if (!smp_make_safe(smp))
return 0;
smp->data.type = SMP_T_BOOL;
smp->data.u.sint = proxy_fe_by_name(smp->data.u.str.area) != NULL;
return 1;
}
/* Note: must not be declared <const> as its list will be overwritten.
* Please take care of keeping this list alphabetically sorted.
@ -344,6 +354,14 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
/* Note: must not be declared <const> as its list will be overwritten */
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
{ "fe_exists", sample_conv_fe_exists, 0, NULL, SMP_T_STR, SMP_T_BOOL },
{ /* END */ },
}};
INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
/* Note: must not be declared <const> as its list will be overwritten.
* Please take care of keeping this list alphabetically sorted.
*/