Introduced a new sample fetch keyword "fe_exist" that checks if a
frontend with a given name exists.
---
 src/frontend.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/frontend.c b/src/frontend.c
index 1df11fcb7..2ca788cbf 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -323,6 +323,16 @@ smp_fetch_fe_tarpit_timeout(const struct arg *args, struct 
sample *smp, const ch
        return 1;
 }
 
+static int
+sample_conv_fe_exist(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.
@@ -341,6 +351,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_exist", sample_conv_fe_exist, 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.
  */
-- 
2.43.0

Reply via email to