You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
MDEV-11159 Add support for sending proxy protocol header
This commit is contained in:
@@ -657,10 +657,12 @@ struct st_default_options mariadb_defaults[] =
|
||||
else \
|
||||
(OPTS)->extension->KEY= NULL
|
||||
|
||||
#define OPT_SET_EXTENDED_VALUE_INT(OPTS, KEY, VAL) \
|
||||
#define OPT_SET_EXTENDED_VALUE(OPTS, KEY, VAL) \
|
||||
CHECK_OPT_EXTENSION_SET(OPTS) \
|
||||
(OPTS)->extension->KEY= (VAL)
|
||||
|
||||
#define OPT_SET_EXTENDED_VALUE_INT(A,B,C) OPT_SET_EXTENDED_VALUE(A,B,C)
|
||||
|
||||
#define OPT_SET_VALUE_STR(OPTS, KEY, VAL) \
|
||||
free((OPTS)->KEY); \
|
||||
if((VAL)) \
|
||||
@@ -1303,6 +1305,17 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (mysql->options.extension && mysql->options.extension->proxy_header)
|
||||
{
|
||||
char *hdr = mysql->options.extension->proxy_header;
|
||||
size_t len = mysql->options.extension->proxy_header_len;
|
||||
if (ma_pvio_write(pvio, hdr, len) <= 0)
|
||||
{
|
||||
ma_pvio_close(pvio);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (ma_net_init(net, pvio))
|
||||
goto error;
|
||||
|
||||
@@ -2955,6 +2968,13 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
|
||||
case MARIADB_OPT_CONNECTION_READ_ONLY:
|
||||
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, read_only, *(my_bool *)arg1);
|
||||
break;
|
||||
case MARIADB_OPT_PROXY_HEADER:
|
||||
{
|
||||
size_t arg2 = va_arg(ap, size_t);
|
||||
OPT_SET_EXTENDED_VALUE(&mysql->options, proxy_header, (char *)arg1);
|
||||
OPT_SET_EXTENDED_VALUE(&mysql->options, proxy_header_len, arg2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
va_end(ap);
|
||||
return(-1);
|
||||
|
Reference in New Issue
Block a user