diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-03-11 10:38:01 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-03-11 16:30:45 -0400 |
commit | 73986ce87913a552858cfd4c187a0f1059324a03 (patch) | |
tree | 5e8437e401115bb043db7098c7e63bec5a290aea /src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp | |
parent | 5fd3dfce18655932165ebadef0bbe5ed58f678de (diff) | |
download | mongo-73986ce87913a552858cfd4c187a0f1059324a03.tar.gz |
SERVER-17496 Move all admin commands to separate files
Diffstat (limited to 'src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp new file mode 100644 index 00000000000..2f9c3a618c5 --- /dev/null +++ b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2015 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/platform/basic.h" + +#include "mongo/db/commands.h" +#include "mongo/s/client_info.h" +#include "mongo/util/net/sock.h" + +namespace mongo { +namespace { + + class WhatsMyUriCmd : public Command { + public: + WhatsMyUriCmd() : Command("whatsmyuri") { } + + virtual bool slaveOk() const { + return true; + } + + virtual bool isWriteCommandForConfigServer() const { + return false; + } + + virtual void help(std::stringstream &help) const { + help << "{whatsmyuri:1}"; + } + + virtual void addRequiredPrivileges(const std::string& dbname, + const BSONObj& cmdObj, + std::vector<Privilege>* out) { + + // No auth required + } + + virtual bool run(OperationContext* txn, + const std::string& dbname, + BSONObj& cmdObj, + int options, + std::string& errmsg, + BSONObjBuilder& result, + bool fromRepl) { + + result << "you" << ClientInfo::get()->getRemote().toString(); + return true; + } + + } whatsMyUriCmd; + +} // namespace +} // namespace mongo |