mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: Add support for UUIDv7 to the uuid
sample fetch
This adds support for UUIDv7 to the existing `uuid` sample fetch that was added
in 8a694b859c
.
This commit is contained in:
parent
aab6477b67
commit
3ef60012ae
@ -21306,7 +21306,8 @@ txn.sess_term_state : string
|
|||||||
uuid([<version>]) : string
|
uuid([<version>]) : string
|
||||||
Returns a UUID following the RFC4122 standard. If the version is not
|
Returns a UUID following the RFC4122 standard. If the version is not
|
||||||
specified, a UUID version 4 (fully random) is returned.
|
specified, a UUID version 4 (fully random) is returned.
|
||||||
Currently, only version 4 is supported.
|
|
||||||
|
Versions 4 and 7 are supported.
|
||||||
|
|
||||||
var(<var-name>[,<default>]) : undefined
|
var(<var-name>[,<default>]) : undefined
|
||||||
Returns a variable with the stored type. If the variable is not set, the
|
Returns a variable with the stored type. If the variable is not set, the
|
||||||
|
42
src/sample.c
42
src/sample.c
@ -4781,10 +4781,15 @@ static int smp_check_uuid(struct arg *args, char **err)
|
|||||||
if (!args[0].type) {
|
if (!args[0].type) {
|
||||||
args[0].type = ARGT_SINT;
|
args[0].type = ARGT_SINT;
|
||||||
args[0].data.sint = 4;
|
args[0].data.sint = 4;
|
||||||
}
|
} else {
|
||||||
else if (args[0].data.sint != 4) {
|
switch (args[0].data.sint) {
|
||||||
memprintf(err, "Unsupported UUID version: '%lld'", args[0].data.sint);
|
case 4:
|
||||||
return 0;
|
case 7:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
memprintf(err, "Unsupported UUID version: '%lld'", args[0].data.sint);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -4793,16 +4798,29 @@ static int smp_check_uuid(struct arg *args, char **err)
|
|||||||
// Generate a RFC4122 UUID (default is v4 = fully random)
|
// Generate a RFC4122 UUID (default is v4 = fully random)
|
||||||
static int smp_fetch_uuid(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
static int smp_fetch_uuid(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||||
{
|
{
|
||||||
if (args[0].data.sint == 4 || !args[0].type) {
|
long long int type = -1;
|
||||||
ha_generate_uuid_v4(&trash);
|
|
||||||
smp->data.type = SMP_T_STR;
|
if (!args[0].type) {
|
||||||
smp->flags = SMP_F_VOL_TEST | SMP_F_MAY_CHANGE;
|
type = 4;
|
||||||
smp->data.u.str = trash;
|
} else {
|
||||||
return 1;
|
type = args[0].data.sint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// more implementations of other uuid formats possible here
|
switch (type) {
|
||||||
return 0;
|
case 4:
|
||||||
|
ha_generate_uuid_v4(&trash);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
ha_generate_uuid_v7(&trash);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
smp->data.type = SMP_T_STR;
|
||||||
|
smp->flags = SMP_F_VOL_TEST | SMP_F_MAY_CHANGE;
|
||||||
|
smp->data.u.str = trash;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if QUIC support was compiled and was not disabled by "no-quic" global option */
|
/* Check if QUIC support was compiled and was not disabled by "no-quic" global option */
|
||||||
|
Loading…
Reference in New Issue
Block a user