mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-27 14:41:28 +01:00
MINOR: backend: srv_queue helper
In preparation of providing further server converters, split the code for finding the server from the sample out. Additionally, update the documentation for srv_queue converter to note security concerns.
This commit is contained in:
parent
b3b910cc3f
commit
faba98c85f
@ -21410,7 +21410,10 @@ srv_queue
|
|||||||
format and returns the number of queued streams on that server. Can be used
|
format and returns the number of queued streams on that server. Can be used
|
||||||
in places where we want to look up queued streams from a dynamic name, like a
|
in places where we want to look up queued streams from a dynamic name, like a
|
||||||
cookie value (e.g. req.cook(SRVID),srv_queue) and then make a decision to break
|
cookie value (e.g. req.cook(SRVID),srv_queue) and then make a decision to break
|
||||||
persistence or direct a request elsewhere.
|
persistence or direct a request elsewhere. Before using this, please keep in
|
||||||
|
mind that using this converter on uncontrolled data might allow an external
|
||||||
|
observer to query the state of any server in the whole configuration, which
|
||||||
|
might possibly not be acceptable in some environments.
|
||||||
|
|
||||||
strcmp(<var>)
|
strcmp(<var>)
|
||||||
Compares the contents of <var> with the input value of type string. Returns
|
Compares the contents of <var> with the input value of type string. Returns
|
||||||
|
|||||||
@ -3738,11 +3738,9 @@ static int sample_conv_nbsrv(const struct arg *args, struct sample *smp, void *p
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static struct server *sample_conv_srv(struct sample *smp)
|
||||||
sample_conv_srv_queue(const struct arg *args, struct sample *smp, void *private)
|
|
||||||
{
|
{
|
||||||
struct proxy *px;
|
struct proxy *px;
|
||||||
struct server *srv;
|
|
||||||
char *bksep;
|
char *bksep;
|
||||||
|
|
||||||
if (!smp_make_safe(smp))
|
if (!smp_make_safe(smp))
|
||||||
@ -3754,15 +3752,22 @@ sample_conv_srv_queue(const struct arg *args, struct sample *smp, void *private)
|
|||||||
*bksep = '\0';
|
*bksep = '\0';
|
||||||
px = proxy_find_by_name(smp->data.u.str.area, PR_CAP_BE, 0);
|
px = proxy_find_by_name(smp->data.u.str.area, PR_CAP_BE, 0);
|
||||||
if (!px)
|
if (!px)
|
||||||
return 0;
|
return NULL;
|
||||||
smp->data.u.str.area = bksep + 1;
|
smp->data.u.str.area = bksep + 1;
|
||||||
} else {
|
} else {
|
||||||
if (!(smp->px->cap & PR_CAP_BE))
|
if (!(smp->px->cap & PR_CAP_BE))
|
||||||
return 0;
|
return NULL;
|
||||||
px = smp->px;
|
px = smp->px;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = server_find(px, smp->data.u.str.area);
|
return server_find(px, smp->data.u.str.area);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sample_conv_srv_queue(const struct arg *args, struct sample *smp, void *private)
|
||||||
|
{
|
||||||
|
struct server *srv = sample_conv_srv(smp);
|
||||||
|
|
||||||
if (!srv)
|
if (!srv)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user