mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
[MINOR] acl: provide a reference to the expr to fetch()
The fetch() functions may need to access the full expr to get their args. Turn the void *arg into a struct acl_expr *expr.
This commit is contained in:
parent
bb76891d0f
commit
97be145991
@ -130,10 +130,12 @@ struct session;
|
|||||||
* successive calls.
|
* successive calls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct acl_expr;
|
||||||
struct acl_keyword {
|
struct acl_keyword {
|
||||||
const char *kw;
|
const char *kw;
|
||||||
int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque);
|
int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque);
|
||||||
int (*fetch)(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test);
|
int (*fetch)(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test);
|
||||||
int (*match)(struct acl_test *test, struct acl_pattern *pattern);
|
int (*match)(struct acl_test *test, struct acl_pattern *pattern);
|
||||||
int use_cnt;
|
int use_cnt;
|
||||||
};
|
};
|
||||||
|
@ -659,7 +659,7 @@ int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, v
|
|||||||
/* we need to reset context and flags */
|
/* we need to reset context and flags */
|
||||||
memset(&test, 0, sizeof(test));
|
memset(&test, 0, sizeof(test));
|
||||||
fetch_next:
|
fetch_next:
|
||||||
if (!expr->kw->fetch(px, l4, l7, dir, expr->arg.str, &test))
|
if (!expr->kw->fetch(px, l4, l7, dir, expr, &test))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* apply all tests to this value */
|
/* apply all tests to this value */
|
||||||
|
15
src/client.c
15
src/client.c
@ -454,7 +454,8 @@ int event_accept(int fd) {
|
|||||||
|
|
||||||
/* set test->ptr to point to the source IPv4/IPv6 address and test->i to the family */
|
/* set test->ptr to point to the source IPv4/IPv6 address and test->i to the family */
|
||||||
static int
|
static int
|
||||||
acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
test->i = l4->cli_addr.ss_family;
|
test->i = l4->cli_addr.ss_family;
|
||||||
if (test->i == AF_INET)
|
if (test->i == AF_INET)
|
||||||
@ -468,7 +469,8 @@ acl_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir, void *arg
|
|||||||
|
|
||||||
/* set test->i to the connexion's source port */
|
/* set test->i to the connexion's source port */
|
||||||
static int
|
static int
|
||||||
acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
if (l4->cli_addr.ss_family == AF_INET)
|
if (l4->cli_addr.ss_family == AF_INET)
|
||||||
test->i = ntohs(((struct sockaddr_in *)&l4->cli_addr)->sin_port);
|
test->i = ntohs(((struct sockaddr_in *)&l4->cli_addr)->sin_port);
|
||||||
@ -481,7 +483,8 @@ acl_fetch_sport(struct proxy *px, struct session *l4, void *l7, int dir, void *a
|
|||||||
|
|
||||||
/* set test->ptr to point to the frontend's IPv4/IPv6 address and test->i to the family */
|
/* set test->ptr to point to the frontend's IPv4/IPv6 address and test->i to the family */
|
||||||
static int
|
static int
|
||||||
acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
if (!(l4->flags & SN_FRT_ADDR_SET))
|
if (!(l4->flags & SN_FRT_ADDR_SET))
|
||||||
get_frt_addr(l4);
|
get_frt_addr(l4);
|
||||||
@ -498,7 +501,8 @@ acl_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir, void *arg
|
|||||||
|
|
||||||
/* set test->i to the frontend connexion's destination port */
|
/* set test->i to the frontend connexion's destination port */
|
||||||
static int
|
static int
|
||||||
acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
if (!(l4->flags & SN_FRT_ADDR_SET))
|
if (!(l4->flags & SN_FRT_ADDR_SET))
|
||||||
get_frt_addr(l4);
|
get_frt_addr(l4);
|
||||||
@ -513,7 +517,8 @@ acl_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir, void *a
|
|||||||
|
|
||||||
/* set test->i to the number of connexions to the proxy */
|
/* set test->i to the number of connexions to the proxy */
|
||||||
static int
|
static int
|
||||||
acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
test->i = px->feconn;
|
test->i = px->feconn;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -5165,7 +5165,8 @@ static int acl_parse_meth(const char **text, struct acl_pattern *pattern, int *o
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acl_fetch_meth(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_meth(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
int meth;
|
int meth;
|
||||||
struct http_txn *txn = l7;
|
struct http_txn *txn = l7;
|
||||||
@ -5209,7 +5210,8 @@ static int acl_parse_ver(const char **text, struct acl_pattern *pattern, int *op
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
struct http_txn *txn = l7;
|
struct http_txn *txn = l7;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -5230,7 +5232,8 @@ acl_fetch_rqver(struct proxy *px, struct session *l4, void *l7, int dir, void *a
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
struct http_txn *txn = l7;
|
struct http_txn *txn = l7;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -5252,7 +5255,8 @@ acl_fetch_stver(struct proxy *px, struct session *l4, void *l7, int dir, void *a
|
|||||||
|
|
||||||
/* 3. Check on Status Code. We manipulate integers here. */
|
/* 3. Check on Status Code. We manipulate integers here. */
|
||||||
static int
|
static int
|
||||||
acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
struct http_txn *txn = l7;
|
struct http_txn *txn = l7;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@ -5268,7 +5272,8 @@ acl_fetch_stcode(struct proxy *px, struct session *l4, void *l7, int dir, void *
|
|||||||
|
|
||||||
/* 4. Check on URL/URI. A pointer to the URI is stored. */
|
/* 4. Check on URL/URI. A pointer to the URI is stored. */
|
||||||
static int
|
static int
|
||||||
acl_fetch_url(struct proxy *px, struct session *l4, void *l7, int dir, void *arg, struct acl_test *test)
|
acl_fetch_url(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
{
|
{
|
||||||
struct http_txn *txn = l7;
|
struct http_txn *txn = l7;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user