mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-10 11:11:37 +00:00
MINOR: ssl: adds sample converter base64 for binary type.
The new converter encode binary type sample to base64 string. i.e. : ssl_c_serial,base64
This commit is contained in:
parent
55f4fa8825
commit
53d1a98270
@ -9535,6 +9535,11 @@ support some arguments (eg: a netmask) which must be passed in parenthesis.
|
|||||||
|
|
||||||
The currently available list of transformation keywords include :
|
The currently available list of transformation keywords include :
|
||||||
|
|
||||||
|
base64
|
||||||
|
Converts a binary input sample to a base64 string. It is used to log or
|
||||||
|
transfer binary content in a way that can be reliably transferred (eg:
|
||||||
|
an SSL ID can be copied in a header).
|
||||||
|
|
||||||
lower
|
lower
|
||||||
Convert a string sample to lower case. This can only be placed after a string
|
Convert a string sample to lower case. This can only be placed after a string
|
||||||
sample fetch function or after a transformation keyword returning a string
|
sample fetch function or after a transformation keyword returning a string
|
||||||
|
19
src/sample.c
19
src/sample.c
@ -20,6 +20,7 @@
|
|||||||
#include <common/chunk.h>
|
#include <common/chunk.h>
|
||||||
#include <common/standard.h>
|
#include <common/standard.h>
|
||||||
#include <common/uri_auth.h>
|
#include <common/uri_auth.h>
|
||||||
|
#include <common/base64.h>
|
||||||
|
|
||||||
#include <proto/arg.h>
|
#include <proto/arg.h>
|
||||||
#include <proto/auth.h>
|
#include <proto/auth.h>
|
||||||
@ -1172,6 +1173,23 @@ struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l
|
|||||||
/* These functions set the data type on return. */
|
/* These functions set the data type on return. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|
||||||
|
static int sample_conv_bin2base64(const struct arg *arg_p, struct sample *smp)
|
||||||
|
{
|
||||||
|
struct chunk *trash = get_trash_chunk();
|
||||||
|
int b64_len;
|
||||||
|
|
||||||
|
trash->len = 0;
|
||||||
|
b64_len = a2base64(smp->data.str.str, smp->data.str.len, trash->str, trash->size);
|
||||||
|
if (b64_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
trash->len = b64_len;
|
||||||
|
smp->data.str = *trash;
|
||||||
|
smp->type = SMP_T_STR;
|
||||||
|
smp->flags &= ~SMP_F_CONST;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp)
|
static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp)
|
||||||
{
|
{
|
||||||
struct chunk *trash = get_trash_chunk();
|
struct chunk *trash = get_trash_chunk();
|
||||||
@ -1329,6 +1347,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
|
|||||||
|
|
||||||
/* Note: must not be declared <const> as its list will be overwritten */
|
/* Note: must not be declared <const> as its list will be overwritten */
|
||||||
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
||||||
|
{ "base64", sample_conv_bin2base64,0, NULL, SMP_T_BIN, SMP_T_STR },
|
||||||
{ "upper", sample_conv_str2upper, 0, NULL, SMP_T_STR, SMP_T_STR },
|
{ "upper", sample_conv_str2upper, 0, NULL, SMP_T_STR, SMP_T_STR },
|
||||||
{ "lower", sample_conv_str2lower, 0, NULL, SMP_T_STR, SMP_T_STR },
|
{ "lower", sample_conv_str2lower, 0, NULL, SMP_T_STR, SMP_T_STR },
|
||||||
{ "hex", sample_conv_bin2hex, 0, NULL, SMP_T_BIN, SMP_T_STR },
|
{ "hex", sample_conv_bin2hex, 0, NULL, SMP_T_BIN, SMP_T_STR },
|
||||||
|
Loading…
Reference in New Issue
Block a user