From 8715ba5c82af165f783ef8bc90b4d8d5a8072175 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Thu, 29 Aug 2019 22:08:54 +0300 Subject: wip: SSL code reorganization, see #705. --- hiredis.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'hiredis.h') diff --git a/hiredis.h b/hiredis.h index d76a9e3..68afb26 100644 --- a/hiredis.h +++ b/hiredis.h @@ -78,9 +78,6 @@ struct timeval; /* forward declaration */ /* Flag that is set when we should set SO_REUSEADDR before calling bind() */ #define REDIS_REUSEADDR 0x80 -/* Flag that is set when this connection is done through SSL */ -#define REDIS_SSL 0x100 - /** * Flag that indicates the user does not want the context to * be automatically freed upon error @@ -193,8 +190,21 @@ typedef struct { (opts)->type = REDIS_CONN_UNIX; \ (opts)->endpoint.unix_socket = path; +struct redisAsyncContext; +struct redisContext; + +typedef struct redisContextFuncs { + void (*free_privdata)(void *); + void (*async_read)(struct redisAsyncContext *); + void (*async_write)(struct redisAsyncContext *); + int (*read)(struct redisContext *, char *, size_t); + int (*write)(struct redisContext *); +} redisContextFuncs; + /* Context for a connection to Redis */ typedef struct redisContext { + redisContextFuncs *funcs; /* Function table */ + int err; /* Error flags, 0 when there is no error */ char errstr[128]; /* String representation of error when applicable */ redisFD fd; @@ -218,9 +228,9 @@ typedef struct redisContext { /* For non-blocking connect */ struct sockadr *saddr; size_t addrlen; - /* For SSL communication */ - struct redisSsl *ssl; + /* Additional private data for hiredis addons such as SSL */ + void *privdata; } redisContext; redisContext *redisConnectWithOptions(const redisOptions *options); @@ -236,13 +246,6 @@ redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval redisContext *redisConnectUnixNonBlock(const char *path); redisContext *redisConnectFd(redisFD fd); -/** - * Secure the connection using SSL. This should be done before any command is - * executed on the connection. - */ -int redisSecureConnection(redisContext *c, const char *capath, const char *certpath, - const char *keypath, const char *servername); - /** * Reconnect the given context using the saved information. * -- cgit v1.2.3