Ejemplo n.º 1
0
    // todo: remove or add clone support
    ConnectionSettings::ConnectionSettings(const mongo::MongoURI& uri, bool isClone)  
        : _connectionName(defaultNameConnection),
        _host(defaultServerHost),
        _port(port),
        _imported(false),
        _sshSettings(new SshSettings()),
        _sslSettings(new SslSettings()),
        _isReplicaSet((uri.type() == mongo::ConnectionString::ConnectionType::SET)),
        _replicaSetSettings(new ReplicaSetSettings(uri)),
        _clone(isClone),
        _uuid(QUuid::createUuid().toString())   // todo
    {
        if (!uri.getServers().empty()) {
            _host = uri.getServers().front().host();
            _port = uri.getServers().front().port();
        }

        auto str = std::string(uri.getOptions().getStringField("ssl"));
        auto sslEnabled = ("true" == str);
        if (sslEnabled) {
            _sslSettings->enableSSL(true);
            _sslSettings->setAllowInvalidCertificates(true);
        }

        auto credential = new CredentialSettings();
        credential->setUserName(uri.getUser());
        credential->setUserPassword(uri.getPassword());
        credential->setDatabaseName(uri.getDatabase());
        if (!credential->userName().empty() && !credential->userPassword().empty()) {   // todo:
            credential->setEnabled(true);
        }
        addCredential(credential);
    }
Ejemplo n.º 2
0
 ReplicaSetSettings::ReplicaSetSettings(const mongo::MongoURI& uri)
     : ReplicaSetSettings() 
 {
     _setName = uri.getSetName();
     for (auto const& server : uri.getServers()) {
         _members.push_back(server.host() + ":" + std::to_string(server.port()));
     }
 }