diff options
Diffstat (limited to 'src/mongo/executor/connection_pool_tl.cpp')
| -rw-r--r-- | src/mongo/executor/connection_pool_tl.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/mongo/executor/connection_pool_tl.cpp b/src/mongo/executor/connection_pool_tl.cpp index 49bccf97b38..e6917ff4342 100644 --- a/src/mongo/executor/connection_pool_tl.cpp +++ b/src/mongo/executor/connection_pool_tl.cpp @@ -33,7 +33,6 @@ #include "mongo/executor/connection_pool_tl.h" -#include "mongo/base/error_codes.h" #include "mongo/client/authenticate.h" #include "mongo/config.h" #include "mongo/db/auth/authorization_manager.h" @@ -172,7 +171,7 @@ public: explicit TLConnectionSetupHook(executor::NetworkConnectionHook* hookToWrap, bool x509AuthOnly) : _wrappedHook(hookToWrap), _x509AuthOnly(x509AuthOnly) {} - BSONObj augmentHelloRequest(const HostAndPort& remoteHost, BSONObj cmdObj) override { + BSONObj augmentIsMasterRequest(const HostAndPort& remoteHost, BSONObj cmdObj) override { BSONObjBuilder bob(std::move(cmdObj)); bob.append("hangUpOnStepDown", false); auto systemUser = internalSecurity.getUser(); @@ -190,9 +189,9 @@ public: } Status validateHost(const HostAndPort& remoteHost, - const BSONObj& helloRequest, - const RemoteCommandResponse& helloReply) override try { - const auto& reply = helloReply.data; + const BSONObj& isMasterRequest, + const RemoteCommandResponse& isMasterReply) override try { + const auto& reply = isMasterReply.data; // X.509 auth only means we only want to use a single mechanism regards of what hello says if (_x509AuthOnly) { @@ -216,7 +215,7 @@ public: if (!_wrappedHook) { return Status::OK(); } else { - return _wrappedHook->validateHost(remoteHost, helloRequest, helloReply); + return _wrappedHook->validateHost(remoteHost, isMasterRequest, isMasterReply); } } catch (const DBException& e) { return e.toStatus(); @@ -327,42 +326,37 @@ void TLConnection::setup(Milliseconds timeout, SetupCallback cb, std::string ins #endif // For transient connections, only use X.509 auth. - auto helloHook = std::make_shared<TLConnectionSetupHook>(_onConnectHook, x509AuthOnly); + auto isMasterHook = std::make_shared<TLConnectionSetupHook>(_onConnectHook, x509AuthOnly); AsyncDBClient::connect( _peer, _sslMode, _serviceContext, _reactor, timeout, _transientSSLContext) .thenRunOn(_reactor) .onError([](StatusWith<AsyncDBClient::Handle> swc) -> StatusWith<AsyncDBClient::Handle> { - if (const Status& status = swc.getStatus(); - status.code() == ErrorCodes::ConnectionError) { - return status; - } else { - return Status(ErrorCodes::HostUnreachable, status.reason()); - } + return Status(ErrorCodes::HostUnreachable, swc.getStatus().reason()); }) - .then([this, helloHook, instanceName = std::move(instanceName)]( + .then([this, isMasterHook, instanceName = std::move(instanceName)]( AsyncDBClient::Handle client) { _client = std::move(client); - return _client->initWireVersion(instanceName, helloHook.get()); + return _client->initWireVersion(instanceName, isMasterHook.get()); }) - .then([this, helloHook]() -> Future<bool> { + .then([this, isMasterHook]() -> Future<bool> { if (_skipAuth) { return false; } - return _client->completeSpeculativeAuth(helloHook->getSession(), + return _client->completeSpeculativeAuth(isMasterHook->getSession(), auth::getInternalAuthDB(), - helloHook->getSpeculativeAuthenticateReply(), - helloHook->getSpeculativeAuthType()); + isMasterHook->getSpeculativeAuthenticateReply(), + isMasterHook->getSpeculativeAuthType()); }) - .then([this, helloHook, authParametersProvider](bool authenticatedDuringConnect) { + .then([this, isMasterHook, authParametersProvider](bool authenticatedDuringConnect) { if (_skipAuth || authenticatedDuringConnect) { return Future<void>::makeReady(); } boost::optional<std::string> mechanism; - if (!helloHook->saslMechsForInternalAuth().empty()) - mechanism = helloHook->saslMechsForInternalAuth().front(); + if (!isMasterHook->saslMechsForInternalAuth().empty()) + mechanism = isMasterHook->saslMechsForInternalAuth().front(); return _client->authenticateInternal(std::move(mechanism), authParametersProvider); }) .then([this] { @@ -420,7 +414,8 @@ void TLConnection::refresh(Milliseconds timeout, RefreshCallback cb) { }); _client - ->runCommandRequest({_peer, std::string("admin"), BSON("hello" << 1), BSONObj(), nullptr}) + ->runCommandRequest( + {_peer, std::string("admin"), BSON("isMaster" << 1), BSONObj(), nullptr}) .then([](executor::RemoteCommandResponse response) { return Future<void>::makeReady(response.status); }) |
