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:
@@ -69,6 +69,8 @@ struct st_mysql_options_extension {
|
|||||||
my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);
|
my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);
|
||||||
HASH userdata;
|
HASH userdata;
|
||||||
char *server_public_key;
|
char *server_public_key;
|
||||||
|
char *proxy_header;
|
||||||
|
size_t proxy_header_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct st_connection_handler
|
typedef struct st_connection_handler
|
||||||
|
@@ -231,7 +231,8 @@ extern const char *SQLSTATE_UNKNOWN;
|
|||||||
MARIADB_OPT_FOUND_ROWS,
|
MARIADB_OPT_FOUND_ROWS,
|
||||||
MARIADB_OPT_MULTI_RESULTS,
|
MARIADB_OPT_MULTI_RESULTS,
|
||||||
MARIADB_OPT_MULTI_STATEMENTS,
|
MARIADB_OPT_MULTI_STATEMENTS,
|
||||||
MARIADB_OPT_INTERACTIVE
|
MARIADB_OPT_INTERACTIVE,
|
||||||
|
MARIADB_OPT_PROXY_HEADER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mariadb_value {
|
enum mariadb_value {
|
||||||
|
@@ -657,10 +657,12 @@ struct st_default_options mariadb_defaults[] =
|
|||||||
else \
|
else \
|
||||||
(OPTS)->extension->KEY= NULL
|
(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) \
|
CHECK_OPT_EXTENSION_SET(OPTS) \
|
||||||
(OPTS)->extension->KEY= (VAL)
|
(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) \
|
#define OPT_SET_VALUE_STR(OPTS, KEY, VAL) \
|
||||||
free((OPTS)->KEY); \
|
free((OPTS)->KEY); \
|
||||||
if((VAL)) \
|
if((VAL)) \
|
||||||
@@ -1303,6 +1305,17 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
|
|||||||
goto error;
|
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))
|
if (ma_net_init(net, pvio))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@@ -2955,6 +2968,13 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
|
|||||||
case MARIADB_OPT_CONNECTION_READ_ONLY:
|
case MARIADB_OPT_CONNECTION_READ_ONLY:
|
||||||
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, read_only, *(my_bool *)arg1);
|
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, read_only, *(my_bool *)arg1);
|
||||||
break;
|
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:
|
default:
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@@ -451,7 +451,7 @@ int ma_tls_verify_server_cert(MARIADB_TLS *ctls)
|
|||||||
if (pszServerName && (sctx->mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT))
|
if (pszServerName && (sctx->mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT))
|
||||||
{
|
{
|
||||||
DWORD NameSize= 0;
|
DWORD NameSize= 0;
|
||||||
char *p1, *p2;
|
char *p1;
|
||||||
SECURITY_STATUS sRet;
|
SECURITY_STATUS sRet;
|
||||||
|
|
||||||
if ((sRet= QueryContextAttributes(&sctx->ctxt, SECPKG_ATTR_REMOTE_CERT_CONTEXT, (PVOID)&pServerCert)) != SEC_E_OK)
|
if ((sRet= QueryContextAttributes(&sctx->ctxt, SECPKG_ATTR_REMOTE_CERT_CONTEXT, (PVOID)&pServerCert)) != SEC_E_OK)
|
||||||
|
Reference in New Issue
Block a user