MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parseProtocolsConfig

Function parseProtocolsConfig

app/redis-6.2.6/src/tls.c:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58SSL_CTX *redis_tls_client_ctx = NULL;
59
60static int parseProtocolsConfig(const char *str) {
61 int i, count = 0;
62 int protocols = 0;
63
64 if (!str) return REDIS_TLS_PROTO_DEFAULT;
65 sds *tokens = sdssplitlen(str, strlen(str), " ", 1, &count);
66
67 if (!tokens) {
68 serverLog(LL_WARNING, "Invalid tls-protocols configuration string");
69 return -1;
70 }
71 for (i = 0; i < count; i++) {
72 if (!strcasecmp(tokens[i], "tlsv1")) protocols |= REDIS_TLS_PROTO_TLSv1;
73 else if (!strcasecmp(tokens[i], "tlsv1.1")) protocols |= REDIS_TLS_PROTO_TLSv1_1;
74 else if (!strcasecmp(tokens[i], "tlsv1.2")) protocols |= REDIS_TLS_PROTO_TLSv1_2;
75 else if (!strcasecmp(tokens[i], "tlsv1.3")) {
76#ifdef TLS1_3_VERSION
77 protocols |= REDIS_TLS_PROTO_TLSv1_3;
78#else
79 serverLog(LL_WARNING, "TLSv1.3 is specified in tls-protocols but not supported by OpenSSL.");
80 protocols = -1;
81 break;
82#endif
83 } else {
84 serverLog(LL_WARNING, "Invalid tls-protocols specified. "
85 "Use a combination of 'TLSv1', 'TLSv1.1', 'TLSv1.2' and 'TLSv1.3'.");
86 protocols = -1;
87 break;
88 }
89 }
90 sdsfreesplitres(tokens, count);
91
92 return protocols;
93}
94
95/* list of connections with pending data already read from the socket, but not
96 * served to the reader yet. */

Callers 1

tlsConfigureFunction · 0.85

Calls 3

sdssplitlenFunction · 0.85
strcasecmpFunction · 0.85
sdsfreesplitresFunction · 0.85

Tested by

no test coverage detected