/usr/include/mongo/client/options.h is in libmongoclient-dev 1.1.2-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | /* Copyright 2014 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <string>
#include "mongo/client/export_macros.h"
#include "mongo/logger/log_domain.h"
#include "mongo/logger/message_log_domain.h"
#include "mongo/stdx/functional.h"
namespace mongo {
namespace client {
/** The Options structure is passed to mongo::client::initialize to configure various
* properties and configurations of the driver.
*/
class MONGO_CLIENT_API Options {
public:
// Defaults for non-boolean or std::string parameters that are not defaulted to the
// empty string. These are useful in case you which to set a parameter to a scale
// factor or mutation of the default.
static const unsigned int kDefaultAutoShutdownGracePeriodMillis = 0;
static const int kDefaultDefaultLocalThresholdMillis = 15;
// Helpful typedefs for logging-related options
typedef std::auto_ptr<logger::MessageLogDomain::EventAppender> LogAppenderPtr;
typedef stdx::function<LogAppenderPtr()> LogAppenderFactory;
/** Obtains the currently configured options for the driver. This method
* must not be called before mongo::client::initialize has completed.
*/
static const Options& current();
/** Constructs a default options object with default values for all options. The
* default option values are documented with each mutator.
*/
Options();
/** The default ports where different mongodb servers tend to run */
enum DefaultPorts { kDbServer = 27017, kShardServer = 27018, kConfigServer = 27019 };
/** The possible modes for SSL support in an SSL enabled build of the driver. */
enum SSLModes {
/** Don't attempt to make SSL connections, or require SSL support of the server. */
kSSLDisabled,
/** Attempt SSL connections, but fall back to no SSL if server does not support.
*
* NOTE: The driver does not currently offer this mode.
*/
// kSSLPreferred,
/** Require SLL. */
kSSLRequired
};
/** The TLS protocols */
enum TLSProtocol { kTLS1_0, kTLS1_1, kTLS1_2 };
//
// Startup and shutdown
//
/** If true, the driver will automatically schedule a client::shutdown via
* 'std::atexit'. If false, the user of the library is responsible for calling
* 'client::shutdown'. Not all platforms support this option (notably, the Windows DLL
* build of the driver does not), so the default value of this parameter is
* 'false'. If this parameter is set to 'true' and the platform cannot honor the
* request to enable 'atexit' termination, 'mongo::client::initialize' will return a
* non-OK status.
*
* Default: false
*/
Options& setCallShutdownAtExit(bool value = true);
bool callShutdownAtExit() const;
/** The grace period used when calling client::shutdown from atexit. If
* 'callShutdownAtExit' is false, this parameter has no effect.
*
* Default: 0 ms (wait forever).
*/
Options& setAutoShutdownGracePeriodMillis(unsigned int millis);
unsigned int autoShutdownGracePeriodMillis() const;
//
// Replication
//
/** Set the default threshold to consider a node local.
*
* Default: 15 ms
*/
Options& setDefaultLocalThresholdMillis(int millis);
int defaultLocalThresholdMillis() const;
//
// SSL
//
// NOTE: None of the below settings have any effect unless the driver
// was compiled with SSL support.
//
// Glossary:
// - CA File: certificate authority certificate file
// - PEM Key File: SSL certificate file in PEM format
// - CRL: certificate revocation list
// - FIPS Mode: OpenSSL crypto library FIPS 140-2 mode processing
//
/** If set to kSSLRequired, the driver will use SSL when connecting.
*
* Default: kSSLDisabled
*/
Options& setSSLMode(SSLModes sslMode = kSSLRequired);
SSLModes SSLMode() const;
/** A convenience: returns true if SSL is not disabled (preferred or required). */
inline bool SSLEnabled() const {
return SSLMode() != kSSLDisabled;
}
/** Sets whether to operate in FIPS mode.
*
* Default: false
*/
Options& setFIPSMode(bool value = true);
const bool FIPSMode() const;
/** Allow disabling particular TLS protocols
*
* Default: OpenSSL default
*/
Options& setSSLDisabledTLSProtocols(const std::vector<TLSProtocol>& protocols);
const std::vector<TLSProtocol>& SSLDisabledTLSProtocols() const;
/** Configure the SSL CA file to use. Has no effect if 'useSSL' is false.
*
* Default: false
*/
Options& setSSLCAFile(const std::string& fileName);
const std::string& SSLCAFile() const;
/** Configure the SSL PEM key file to use. Has no effect if 'useSSL' is false.
*
* Default: <empty>
*/
Options& setSSLPEMKeyFile(const std::string& fileName);
const std::string& SSLPEMKeyFile() const;
/** Configure the SSL PEM key password. Has no effect if 'useSSL' is false.
*
* Default: <empty>
*/
Options& setSSLPEMKeyPassword(const std::string& password);
const std::string& SSLPEMKeyPassword() const;
/** Configure the SSL CRL file to use. Has no effect if 'useSSL' is false.
*
* Default: <empty>
*/
Options& setSSLCRLFile(const std::string& fileName);
const std::string& SSLCRLFile() const;
/** When set true, SSL certificate validation is disabled.
*
* Default: false
*/
Options& setSSLAllowInvalidCertificates(bool value = true);
const bool SSLAllowInvalidCertificates() const;
/** When set true, SSL hostname validation is disabled.
*
* Default: false
*/
Options& setSSLAllowInvalidHostnames(bool value = true);
const bool SSLAllowInvalidHostnames() const;
/** Override the default OpenSSL cipher configuration
*
* Default: OpenSSL default
*/
Options& setSSLCipherConfig(const std::string& config);
const std::string& SSLCipherConfig() const;
//
// Logging
//
/** Provide a factory for a log appender to configure logging.
*
* Default: no log appender, and logging is not enabled.
*/
Options& setLogAppenderFactory(const LogAppenderFactory& factory);
const LogAppenderFactory& logAppenderFactory() const;
/** Specify the minimum severity of messages that will be logged, if logging
* is enabled.
*
* Default: LogSeverity::Log()
*/
Options& setMinLoggedSeverity(logger::LogSeverity level);
logger::LogSeverity minLoggedSeverity() const;
//
// Networking
//
/** Enable support for the IPv6 protocol family.
*
* Default: false
*/
Options& setIPv6Enabled(bool state);
bool IPv6Enabled() const;
//
// Misc
//
/** Configure whether BSON objects returned from the server should be validated.
*
* Default: false
*/
Options& setValidateObjects(bool value = true);
bool validateObjects() const;
private:
bool _callShutdownAtExit;
unsigned int _autoShutdownGracePeriodMillis;
SSLModes _sslMode;
bool _useFIPSMode;
std::vector<TLSProtocol> _sslDisabledTLSProtocols;
std::string _sslCAFile;
std::string _sslPEMKeyFile;
std::string _sslPEMKeyPassword;
std::string _sslCRLFile;
bool _sslAllowInvalidCertificates;
bool _sslAllowInvalidHostnames;
std::string _sslCipherConfig;
int _defaultLocalThresholdMillis;
LogAppenderFactory _appenderFactory;
logger::LogSeverity _minLoggedSeverity;
bool _IPv6Enabled;
bool _validateObjects;
};
} // namespace client
} // namespace mongo
|