Skip to content

Commit

Permalink
fix redis cluster tls connection error joeferner#527
Browse files Browse the repository at this point in the history
  • Loading branch information
sseide committed Jun 28, 2023
1 parent 5cedaf4 commit 7676304
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class ConnectionWrapper {
}

// check if it is a standalone or cluster setup if not started as explicit cluster (auto-detect)
if (p[2] && typeof p[2].value === 'string') {
if (typeof p[2].value === 'string') {
const matchAnswer = p[2].value.match(/cluster_enabled:(\d)/)
if (matchAnswer) {
if (matchAnswer[1] === "1") {
Expand All @@ -340,7 +340,8 @@ class ConnectionWrapper {
password: redisConnection.options.password,
foldingChar: redisConnection.options.foldingChar,
label: redisConnection.label,
connectionName: redisConnection.options.connectionName
connectionName: redisConnection.options.connectionName,
tls: redisConnection.options.tls
};
redisConnection.disconnect();
const client = myUtils.createRedisClient(newConnection);
Expand All @@ -350,7 +351,7 @@ class ConnectionWrapper {
}
}
// must exclude "null" as this promise is optional, only for standalone server
else if (p[2] !== null) {
else if (!(p[2].status === 'fulfilled' && p[2].value === null)) {
console.log(`Redis "info cluster" not supported, cannot auto-detect cluster mode on ${redisConnection.options.connectionId}`);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/redisCommands/redisCore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// first start - my be reworked to use 'COMMANDS' or 'COMMAND INFO' command if available (redis >=2.8.13)
// first start - may be reworked to use 'COMMANDS' or 'COMMAND INFO' command if available (redis >=2.8.13)
// but this will be fallback if they are not working (for whatever reason)
const _readCmdsV3 = [
'REFRESH',
Expand Down
1 change: 0 additions & 1 deletion lib/routes/apiv1.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ function getClusterNodes (req, res, next) {
if (res.locals.connection) {
// only one server requested
clusterNodes(res.locals.connection, function(err, nodeInfo) {
let retList = [];
if (err) {
console.error(`Error checking cluster info for a connection: ${res.locals.connectionId} - ${JSON.stringify(err)}`);
return res.json({error: "error reading cluster node info from server"});
Expand Down
7 changes: 2 additions & 5 deletions web/static/scripts/redisCommander.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,16 +894,12 @@ function decodeKey (connectionId, key) {
});
}

function clusterNodes (connectionId, key) {
function clusterNodes (connectionId) {
if (typeof(connectionId) === 'object') {
// context menu click
const node = getKeyTree().get_node(connectionId.reference[0]);
connectionId = getRootConnection(node);
const foldingChar = connections.findById(connectionId).foldingChar
key = getFullKeyPath(node);
if (key.length > 0 && !key.endsWith(foldingChar)) {
key = key + foldingChar;
}
}
$.get('apiv2/server/' + encodeURIComponent(connectionId) + '/cluster/nodes', function (data) {
if (data.error) {
Expand Down Expand Up @@ -1614,6 +1610,7 @@ function selectNewServerDbs() {
});
}


function loadConfig (callback) {
$.get('config', function (data) {
if (data) {
Expand Down
3 changes: 3 additions & 0 deletions web/static/templates/serverInfo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<button class="btn" onclick="addKey('<%= connectionId %>')" style="margin-right: 5px">Add New Key...</button>
<% } %>
<button class="btn btn-danger" onclick="removeServer('<%= connectionId %>')" style="margin-right: 5px">Disconnect</button>
<% if (connectionId.startsWith('C')) { %>
<button class="btn" onclick="clusterNodes('<%= connectionId %>')" style="margin-right: 5px">Cluster Infos</button>
<% } %>
</div>
<div id="itemData">
</div>
Expand Down

0 comments on commit 7676304

Please sign in to comment.