Mention one of rediss:// and valkeys:// in error message, not both (#373)

When using a TLS scheme for valkey-cli and benchmark-cli compiled
without TLS, make the error message only mention the scheme used.

Before:

"valkeys:// and rediss:// are only supported when valkey-cli is compiled
with OpenSSL"

After, depending on which scheme the user tried to use:

"valkeys:// is only supported when valkey-cli is compiled with OpenSSL"
"rediss:// is only supported when valkey-cli is compiled with OpenSSL"

Follow up of #199.

---------

Signed-off-by: karthyuom <karthyuom@gmail.com>
Co-authored-by: k00809413 <karthick.ariyaratnam1@huawei.com>
This commit is contained in:
Karthick Ariyaratnam 2024-04-25 16:02:22 -04:00 committed by GitHub
parent 4948d536b9
commit 9eaefc77b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -328,26 +328,23 @@ void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo
const char *userinfo, *username, *port, *host, *path; const char *userinfo, *username, *port, *host, *path;
/* URI must start with a valid scheme. */ /* URI must start with a valid scheme. */
if (!strncasecmp(tlsscheme, curr, strlen(tlsscheme))) { if (!strncasecmp(tlsscheme, curr, strlen(tlsscheme)) ||
!strncasecmp(redisTlsscheme, curr, strlen(redisTlsscheme))) {
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
*tls_flag = 1; *tls_flag = 1;
curr += strlen(tlsscheme); char *del = strstr(curr, "://");
curr += (del - curr) + 3;
#else #else
fprintf(stderr,"valkeys:// and rediss:// are only supported when %s is compiled with OpenSSL\n", tool_name); char *copy = strdup(curr);
char *curr_scheme = strtok(copy, "://");
fprintf(stderr,"%s:// is only supported when %s is compiled with OpenSSL\n", curr_scheme, tool_name);
free(copy);
exit(1); exit(1);
#endif #endif
} else if (!strncasecmp(redisTlsscheme, curr, strlen(redisTlsscheme))) { } else if (!strncasecmp(scheme, curr, strlen(scheme)) ||
#ifdef USE_OPENSSL !strncasecmp(redisScheme, curr, strlen(redisScheme))) {
*tls_flag = 1; char *del = strstr(curr, "://");
curr += strlen(redisTlsscheme); curr += (del - curr) + 3;
#else
fprintf(stderr,"valkeys:// and rediss:// are only supported when %s is compiled with OpenSSL\n", tool_name);
exit(1);
#endif
} else if (!strncasecmp(scheme, curr, strlen(scheme))) {
curr += strlen(scheme);
} else if (!strncasecmp(redisScheme, curr, strlen(redisScheme))) {
curr += strlen(redisScheme);
} else { } else {
fprintf(stderr,"Invalid URI scheme\n"); fprintf(stderr,"Invalid URI scheme\n");
exit(1); exit(1);