diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-04-23 17:27:07 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-05-14 15:50:55 -0400 |
commit | ad9267a722e21268d1005c1428ccad85d5a98946 (patch) | |
tree | 4af25a065685aef29a20106b3f0f9e05a83c19e8 /src/mongo/shell/replsettest.js | |
parent | a566943aac06895581c16530b953a5724f4177e0 (diff) | |
download | mongo-ad9267a722e21268d1005c1428ccad85d5a98946.tar.gz |
SERVER-4999 Normalize all hostnames to lowercase
Hostnames passed to replSetInitiate, replSetReconfig, addShard, etc. are
all normalized by replacing ASCII uppercase characters with lowercase
characters, consistent with how MongoDB drivers treat hostnames.
The shell's getHostName() function now returns the hostname lowercased.
Fixes undefined behavior in mongo::str::toLower().
Diffstat (limited to 'src/mongo/shell/replsettest.js')
-rw-r--r-- | src/mongo/shell/replsettest.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index df1009e0d66..565fd3fb7b5 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -279,7 +279,8 @@ var ReplSetTest = function(opts) { "/" + node.name); } - if (status.members[i].name == node.host || status.members[i].name == node.name) { + if (status.members[i].name.toLowerCase() == node.host.toLowerCase() || + status.members[i].name.toLowerCase() == node.name.toLowerCase()) { for (var j = 0; j < states.length; j++) { if (printStatus) { print("Status -- " + " current state: " + status.members[i][ind] + @@ -2597,7 +2598,7 @@ var ReplSetTest = function(opts) { print('Starting new replica set ' + self.name); self.useHostName = opts.useHostName == undefined ? true : opts.useHostName; - self.host = self.useHostName ? (opts.host || getHostName()) : 'localhost'; + self.host = (self.useHostName ? (opts.host || getHostName()) : 'localhost').toLowerCase(); self.oplogSize = opts.oplogSize || 40; self.useSeedList = opts.useSeedList || false; self.keyFile = opts.keyFile; @@ -2693,7 +2694,7 @@ var ReplSetTest = function(opts) { self.ports = existingNodes.map(node => node.split(':')[1]); self.nodes = existingNodes.map(node => new Mongo(node)); self.waitForKeys = false; - self.host = existingNodes[0].split(':')[0]; + self.host = existingNodes[0].split(':')[0].toLowerCase(); self.name = conf._id; } |