The name of the initial branch for new projects is now "main" instead of "master". Existing projects remain unchanged. More information: https://doku.lrz.de/display/PUBLIC/GitLab

Commit d153944d authored by Michael Ott's avatar Michael Ott
Browse files

Whitelist only the specified Cassandra server for connections

parent 29777058
......@@ -29,6 +29,7 @@
#include <iostream>
#include <boost/lexical_cast.hpp>
#include <boost/asio.hpp>
#include "cassandra.h"
......@@ -397,6 +398,21 @@ bool ConnectionImpl::connect() {
cass_cluster_set_core_connections_per_host(cluster, coreConnPerHost);
cass_cluster_set_request_timeout(cluster, 60000);
boost::asio::io_service io_service;
boost::asio::ip::tcp::resolver resolver(io_service);
boost::asio::ip::tcp::resolver::query query(hostname_, std::to_string(port_));
boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query);
boost::asio::ip::tcp::resolver::iterator end;
std::string whitelist;
while (iter != end) {
if (whitelist.size() > 0) {
whitelist.append(",");
}
whitelist.append(iter->endpoint().address().to_string());
iter++;
}
cass_cluster_set_whitelist_filtering(cluster, whitelist.c_str());
/* Force protcol version to 4 */
cass_cluster_set_protocol_version(cluster, 4);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment