diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-14 14:26:38 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-14 14:26:38 -0300 |
| commit | 294bc6ecabf14c09c9bc8644704921dcf97cb44e (patch) | |
| tree | 279b1e0bab53901a1647ac63c1c724f0f789a663 /src/mongo/shell/encrypted_dbclient_base.h | |
| parent | 70be7c27a251621187a1de533462ae2bb1e3bd39 (diff) | |
| parent | 1e917fd798aa25b7066d4b414b51184f13d5a092 (diff) | |
Update upstream source from tag 'upstream/6.0.10'debian/6.0.10-1
Update to upstream version '6.0.10'
with Debian dir 2d176fa254eee97b139f712fec5709641335a8c3
Diffstat (limited to 'src/mongo/shell/encrypted_dbclient_base.h')
| -rw-r--r-- | src/mongo/shell/encrypted_dbclient_base.h | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/mongo/shell/encrypted_dbclient_base.h b/src/mongo/shell/encrypted_dbclient_base.h index 4c0a75434fb..f7a7608f70a 100644 --- a/src/mongo/shell/encrypted_dbclient_base.h +++ b/src/mongo/shell/encrypted_dbclient_base.h @@ -102,7 +102,11 @@ public: using DBClientBase::runCommandWithTarget; virtual std::pair<rpc::UniqueReply, DBClientBase*> runCommandWithTarget( - OpMsgRequest request) override; + OpMsgRequest request) final; + + std::pair<rpc::UniqueReply, std::shared_ptr<DBClientBase>> runCommandWithTarget( + OpMsgRequest request, std::shared_ptr<DBClientBase>) final; + std::string toString() const final; int getMinWireVersion() final; @@ -153,6 +157,8 @@ public: bool isMongos() const final; + DBClientBase* getRawConnection(); + #ifdef MONGO_CONFIG_SSL const SSLConfiguration* getSSLConfiguration() override; @@ -164,16 +170,54 @@ public: protected: BSONObj _decryptResponsePayload(BSONObj& reply, StringData databaseName, bool isFLE2); - std::pair<rpc::UniqueReply, DBClientBase*> processResponseFLE1(rpc::UniqueReply result, - StringData databaseName); + enum class RunCommandConnectionType { rawPtr, sharedPtr }; + + struct RunCommandParams { + OpMsgRequest request; + std::shared_ptr<DBClientBase> conn; + RunCommandConnectionType type; + + RunCommandParams(OpMsgRequest request) + : request(std::move(request)), type(RunCommandConnectionType::rawPtr){}; + + RunCommandParams(OpMsgRequest request, std::shared_ptr<DBClientBase> base) + : request(std::move(request)), conn(base), type(RunCommandConnectionType::sharedPtr){}; + + RunCommandParams(OpMsgRequest request, RunCommandParams params) + : request(std::move(request)), type(params.type) { + if (type == RunCommandConnectionType::sharedPtr) { + conn = params.conn; + }; + }; + }; + + using RunCommandReturnConn = stdx::variant<DBClientBase*, std::shared_ptr<DBClientBase>>; + + struct RunCommandReturn { + rpc::UniqueReply returnReply; + RunCommandReturnConn returnConn; + + RunCommandReturn(std::pair<rpc::UniqueReply, DBClientBase*> pair) + : returnReply(std::move(std::get<0>(pair))), returnConn(std::get<1>(pair)) {} + + RunCommandReturn(std::pair<rpc::UniqueReply, std::shared_ptr<DBClientBase>> pair) + : returnReply(std::move(std::get<0>(pair))), returnConn(std::get<1>(pair)) {} + + RunCommandReturn(rpc::UniqueReply reply, RunCommandReturn& result) + : returnReply(std::move(reply)), returnConn(result.returnConn) {} + }; + + RunCommandReturn doRunCommand(RunCommandParams params); + + virtual RunCommandReturn handleEncryptionRequest(RunCommandParams params); - std::pair<rpc::UniqueReply, DBClientBase*> processResponseFLE2(rpc::UniqueReply result, - StringData databaseName); + RunCommandReturn processResponseFLE1(RunCommandReturn result, StringData databaseName); - std::pair<rpc::UniqueReply, DBClientBase*> prepareReply(rpc::UniqueReply result, - StringData databaseName, - BSONObj decryptedDoc); + RunCommandReturn processResponseFLE2(RunCommandReturn result, StringData DatabaseName); + RunCommandReturn prepareReply(RunCommandReturn result, + StringData databaseName, + BSONObj decryptedDoc); BSONObj encryptDecryptCommand(const BSONObj& object, bool encrypt, StringData databaseName); |
