ports to some clients for a whole application session. It is of
type integer and only works with such tables.
+ fe_conn([<frontend>])
+ Returns the number of currently established connections on the
+ the frontend, possibly including the connection being evaluated.
+ If no frontend name is specified, the current one is used. But
+ it is also possible to check another frontend. It can be used to
+ return a sorry page before hard-blocking, or to use a specific
+ backend to drain new requests when the farm is considered full.
+ This is mostly used with ACLs but can also be used to pass some
+ statistics to servers in HTTP headers. See also the "dst_conn",
+ "be_conn", "fe_sess_rate" criteria.
+
+ fe_id Returns an integer containing the current frontend's id.
+
+ fe_sess_rate([<frontend>])
+ Returns an integer value corresponding to the sessions creation
+ rate on the frontend, in number of new sessions per second. This
+ is used with ACLs to limit the incoming session rate to an
+ acceptable range in order to prevent abuse of service at the
+ earliest moment. It can also be useful to add this element to
+ logs using a log-format directive.
+
hdr(<name>[,<occ>])
This extracts the last occurrence of header <name> in an HTTP
request. Optionally, a specific occurrence might be specified as
/*
* Frontend variables and functions.
*
- * Copyright 2000-2011 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2013 Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
#include <proto/proto_tcp.h>
#include <proto/proto_http.h>
#include <proto/proxy.h>
+#include <proto/sample.h>
#include <proto/session.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
return -1;
}
+/************************************************************************/
+/* All supported sample and ACL keywords must be declared here. */
+/************************************************************************/
+
/* set temp integer to the id of the frontend */
static int
-acl_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_SESS;
* an undefined behaviour.
*/
static int
-acl_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
* an undefined behaviour.
*/
static int
-acl_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
}
+/* Note: must not be declared <const> as its list will be overwritten.
+ * Please take care of keeping this list alphabetically sorted.
+ */
+static struct sample_fetch_kw_list smp_kws = {{ },{
+ { "fe_conn", smp_fetch_fe_conn, ARG1(1,FE), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+ { "fe_id", smp_fetch_fe_id, 0, NULL, SMP_T_UINT, SMP_USE_FTEND, },
+ { "fe_sess_rate", smp_fetch_fe_sess_rate, ARG1(1,FE), NULL, SMP_T_UINT, SMP_USE_INTRN, },
+ { /* END */ },
+}};
+
+
/* Note: must not be declared <const> as its list will be overwritten.
* Please take care of keeping this list alphabetically sorted.
*/
static struct acl_kw_list acl_kws = {{ },{
- { "fe_conn", acl_parse_int, acl_fetch_fe_conn, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
- { "fe_id", acl_parse_int, acl_fetch_fe_id, acl_match_int, ACL_USE_NOTHING, 0 },
- { "fe_sess_rate", acl_parse_int, acl_fetch_fe_sess_rate, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
- { NULL, NULL, NULL, NULL },
+ { "fe_conn", acl_parse_int, smp_fetch_fe_conn, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
+ { "fe_id", acl_parse_int, smp_fetch_fe_id, acl_match_int, ACL_USE_NOTHING, 0 },
+ { "fe_sess_rate", acl_parse_int, smp_fetch_fe_sess_rate, acl_match_int, ACL_USE_NOTHING, ARG1(1,FE) },
+ { /* END */ },
}};
__attribute__((constructor))
static void __frontend_init(void)
{
+ sample_register_fetches(&smp_kws);
acl_register_keywords(&acl_kws);
}