Skip to content

Commit

Permalink
Mention one of rediss:// and valkeys:// in error message, not both (v…
Browse files Browse the repository at this point in the history
…alkey-io#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 valkey-io#199.

---------

Signed-off-by: karthyuom <[email protected]>
Co-authored-by: k00809413 <[email protected]>
  • Loading branch information
karthyuom and k00809413 authored Apr 25, 2024
1 parent 4948d53 commit 9eaefc7
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/cli_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,23 @@ void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo
const char *userinfo, *username, *port, *host, *path;

/* 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
*tls_flag = 1;
curr += strlen(tlsscheme);
char *del = strstr(curr, "://");
curr += (del - curr) + 3;
#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);
#endif
} else if (!strncasecmp(redisTlsscheme, curr, strlen(redisTlsscheme))) {
#ifdef USE_OPENSSL
*tls_flag = 1;
curr += strlen(redisTlsscheme);
#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 if (!strncasecmp(scheme, curr, strlen(scheme)) ||
!strncasecmp(redisScheme, curr, strlen(redisScheme))) {
char *del = strstr(curr, "://");
curr += (del - curr) + 3;
} else {
fprintf(stderr,"Invalid URI scheme\n");
exit(1);
Expand Down

0 comments on commit 9eaefc7

Please sign in to comment.