1 | #ifndef __CLICOMMON_H |
2 | #define __CLICOMMON_H |
3 | |
4 | #include <hiredis.h> |
5 | #include <sdscompat.h> /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ |
6 | |
7 | typedef struct cliSSLconfig { |
8 | /* Requested SNI, or NULL */ |
9 | char *sni; |
10 | /* CA Certificate file, or NULL */ |
11 | char *cacert; |
12 | /* Directory where trusted CA certificates are stored, or NULL */ |
13 | char *cacertdir; |
14 | /* Skip server certificate verification. */ |
15 | int skip_cert_verify; |
16 | /* Client certificate to authenticate with, or NULL */ |
17 | char *cert; |
18 | /* Private key file to authenticate with, or NULL */ |
19 | char *key; |
20 | /* Preferred cipher list, or NULL (applies only to <= TLSv1.2) */ |
21 | char* ciphers; |
22 | /* Preferred ciphersuites list, or NULL (applies only to TLSv1.3) */ |
23 | char* ciphersuites; |
24 | } cliSSLconfig; |
25 | |
26 | |
27 | /* server connection information object, used to describe an ip:port pair, db num user input, and user:pass. */ |
28 | typedef struct cliConnInfo { |
29 | char *hostip; |
30 | int hostport; |
31 | int input_dbnum; |
32 | char *auth; |
33 | char *user; |
34 | } cliConnInfo; |
35 | |
36 | int cliSecureConnection(redisContext *c, cliSSLconfig config, const char **err); |
37 | |
38 | ssize_t cliWriteConn(redisContext *c, const char *buf, size_t buf_len); |
39 | |
40 | int cliSecureInit(); |
41 | |
42 | sds readArgFromStdin(void); |
43 | |
44 | sds *getSdsArrayFromArgv(int argc,char **argv, int quoted); |
45 | |
46 | sds unquoteCString(char *str); |
47 | |
48 | void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo, int *tls_flag); |
49 | |
50 | void freeCliConnInfo(cliConnInfo connInfo); |
51 | |
52 | sds escapeJsonString(sds s, const char *p, size_t len); |
53 | |
54 | #endif /* __CLICOMMON_H */ |
55 | |