geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bben...@apache.org
Subject [geode-native] 08/08: WIP: fold in work from ACE-based SNI branch
Date Thu, 13 Aug 2020 18:57:05 GMT
This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch feature/asio
in repository https://gitbox.apache.org/repos/asf/geode-native.git

commit a7c11d15be1c638ba8a9c8f52d9e584212e399fb
Author: Blake Bender <bblake@bblake-a01.vmware.com>
AuthorDate: Thu Aug 13 11:55:25 2020 -0700

    WIP: fold in work from ACE-based SNI branch
---
 cppcache/integration/test/SNITest.cpp | 23 ++++++++++++-----------
 cppcache/src/PoolAttributes.cpp       | 35 +----------------------------------
 cppcache/src/PoolAttributes.hpp       |  3 ---
 cppcache/src/PoolFactory.cpp          | 22 ++++++++++++----------
 cppcache/src/ServerLocation.hpp       |  2 +-
 cppcache/src/TcpSslConn.cpp           |  8 ++++++--
 6 files changed, 32 insertions(+), 61 deletions(-)

diff --git a/cppcache/integration/test/SNITest.cpp b/cppcache/integration/test/SNITest.cpp
index 66d8f8e..6a0215f 100644
--- a/cppcache/integration/test/SNITest.cpp
+++ b/cppcache/integration/test/SNITest.cpp
@@ -28,6 +28,7 @@
 #include <geode/RegionShortcut.hpp>
 
 #include "framework/Cluster.h"
+#include "framework/TestConfig.h"
 
 namespace snitest {
 
@@ -41,6 +42,8 @@ class SNITest : public ::testing::Test {
  protected:
   SNITest() {
     certificatePassword = std::string("apachegeode");
+    clientSslKeysDir = boost::filesystem::path(
+        getFrameworkString(FrameworkVariable::TestClientSslKeysDir));
     currentWorkingDirectory = boost::filesystem::current_path();
   }
 
@@ -108,18 +111,17 @@ class SNITest : public ::testing::Test {
   }
 
   std::string certificatePassword;
+  boost::filesystem::path clientSslKeysDir;
   boost::filesystem::path currentWorkingDirectory;
 };
 
 TEST_F(SNITest, connectViaProxyTest) {
-  auto clientSslKeysDir = boost::filesystem::path(
-      getFrameworkString(FrameworkVariable::TestClientSslKeysDir));
   const auto clientTruststore =
-      (clientSslKeysDir / boost::filesystem::path("truststore_sni.pem"));
+      (clientSslKeysDir / boost::filesystem::path("/truststore_sni.pem"));
 
   auto cache = CacheFactory()
                    .set("log-level", "debug")
-                   .set("log-file", "SNIProxyTest.log")
+                   .set("log-file", "SNITest.log")
                    .set("ssl-enabled", "true")
                    .set("ssl-truststore", clientTruststore.string())
                    .create();
@@ -129,13 +131,13 @@ TEST_F(SNITest, connectViaProxyTest) {
 
   cache.getPoolManager()
       .createFactory()
-      .addLocator("locator-maeve", 10334)
       .setSniProxy("localhost", portNumber)
+      .addLocator("locator-maeve", 10334)
       .create("pool");
 
   auto region = cache.createRegionFactory(RegionShortcut::PROXY)
                     .setPoolName("pool")
-                    .create("region");
+                    .create("jellyfish");
 
   region->put("1", "one");
 
@@ -144,17 +146,17 @@ TEST_F(SNITest, connectViaProxyTest) {
 
 TEST_F(SNITest, connectionFailsTest) {
   const auto clientTruststore =
-      (currentWorkingDirectory /
-       boost::filesystem::path("sni-test-config/geode-config/truststore.jks"));
+      (clientSslKeysDir / boost::filesystem::path("/truststore_sni.pem"));
 
   auto cache = CacheFactory()
-                   .set("log-level", "none")
+                   .set("log-level", "DEBUG")
                    .set("ssl-enabled", "true")
                    .set("ssl-truststore", clientTruststore.string())
                    .create();
 
   cache.getPoolManager()
       .createFactory()
+      .setSniProxy("badProxyName", 40000)
       .addLocator("locator-maeve", 10334)
       .create("pool");
 
@@ -169,8 +171,7 @@ TEST_F(SNITest, connectionFailsTest) {
 
 TEST_F(SNITest, doNothingTest) {
   const auto clientTruststore =
-      (currentWorkingDirectory /
-       boost::filesystem::path("sni-test-config/geode-config/truststore.jks"));
+      (clientSslKeysDir / boost::filesystem::path("/truststore_sni.pem"));
 
   auto cache = CacheFactory()
                    .set("log-level", "DEBUG")
diff --git a/cppcache/src/PoolAttributes.cpp b/cppcache/src/PoolAttributes.cpp
index af77912..206e1a4 100644
--- a/cppcache/src/PoolAttributes.cpp
+++ b/cppcache/src/PoolAttributes.cpp
@@ -46,44 +46,11 @@ PoolAttributes::PoolAttributes()
       m_isPRSingleHopEnabled(PoolFactory::DEFAULT_PR_SINGLE_HOP_ENABLED),
       m_serverGrp(PoolFactory::DEFAULT_SERVER_GROUP),
       m_sniProxyPort(0) {}
+
 std::shared_ptr<PoolAttributes> PoolAttributes::clone() {
   return std::make_shared<PoolAttributes>(*this);
 }
 
-/** Return true if all the attributes are equal to those of other. */
-bool PoolAttributes::operator==(const PoolAttributes& other) const {
-  bool result = false;
-
-  if ((m_isThreadLocalConn == other.m_isThreadLocalConn) &&
-      (m_freeConnTimeout == other.m_freeConnTimeout) &&
-      (m_loadCondInterval == other.m_loadCondInterval) &&
-      (m_sockBufferSize == other.m_sockBufferSize) &&
-      (m_readTimeout == other.m_readTimeout) &&
-      (m_minConns == other.m_minConns) && (m_maxConns == other.m_maxConns) &&
-      (m_retryAttempts == other.m_retryAttempts) &&
-      (m_statsInterval == other.m_statsInterval) &&
-      (m_redundancy == other.m_redundancy) &&
-      (m_msgTrackTimeout == other.m_msgTrackTimeout) &&
-      (m_subsAckInterval == other.m_subsAckInterval) &&
-      (m_idleTimeout == other.m_idleTimeout) &&
-      (m_pingInterval == other.m_pingInterval) &&
-      (m_updateLocatorListInterval == other.m_updateLocatorListInterval) &&
-      (m_subsEnabled == other.m_subsEnabled) &&
-      (m_multiuserSecurityMode == other.m_multiuserSecurityMode) &&
-      (m_isPRSingleHopEnabled == other.m_isPRSingleHopEnabled) &&
-      (m_serverGrp == other.m_serverGrp) &&
-      (m_initLocList.size() == other.m_initLocList.size()) &&
-      (m_initServList.size() == other.m_initServList.size()) &&
-      (compareVectorOfStrings(m_initLocList, other.m_initLocList)) &&
-      (compareVectorOfStrings(m_initServList, other.m_initServList)) &&
-      (m_sniProxyHost == other.m_sniProxyHost) &&
-      (m_sniProxyPort == other.m_sniProxyPort)) {
-    result = true;
-  }
-
-  return result;
-}
-
 bool PoolAttributes::compareVectorOfStrings(
     const std::vector<std::string>& thisVector,
     const std::vector<std::string>& otherVector) {
diff --git a/cppcache/src/PoolAttributes.hpp b/cppcache/src/PoolAttributes.hpp
index d205066..44d9633 100644
--- a/cppcache/src/PoolAttributes.hpp
+++ b/cppcache/src/PoolAttributes.hpp
@@ -176,9 +176,6 @@ class PoolAttributes {
 
   std::shared_ptr<PoolAttributes> clone();
 
-  /** Return true if all the attributes are equal to those of other. */
-  bool operator==(const PoolAttributes& other) const;
-
  private:
   bool m_isThreadLocalConn;
   std::chrono::milliseconds m_freeConnTimeout;
diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp
index 382b9e9..662e0bb 100644
--- a/cppcache/src/PoolFactory.cpp
+++ b/cppcache/src/PoolFactory.cpp
@@ -306,20 +306,22 @@ std::shared_ptr<Pool> PoolFactory::create(std::string name) {
 }
 
 PoolFactory& PoolFactory::addCheck(const std::string& host, int port) {
-  if (port <= 0) {
-    throw IllegalArgumentException("port must be greater than 0 but was " +
-                                   std::to_string(port));
-  }
+  if (m_attrs->getSniProxyHost().empty()) {
+    if (port <= 0) {
+      throw IllegalArgumentException("port must be greater than 0 but was " +
+                                     std::to_string(port));
+    }
 
-  ACE_INET_Addr addr(port, host.c_str());
+    ACE_INET_Addr addr(port, host.c_str());
 #ifdef WITH_IPV6
-  // check unknown host
-  // ACE will not initialize port if hostname is not resolved.
-  if (port != addr.get_port_number()) {
+    // check unknown host
+    // ACE will not initialize port if hostname is not resolved.
+    if (port != addr.get_port_number()) {
 #else
-  if (!(addr.get_ip_address())) {
+    if (!(addr.get_ip_address())) {
 #endif
-    throw IllegalArgumentException("Unknown host " + host);
+      throw IllegalArgumentException("Unknown host " + host);
+    }
   }
   return *this;
 }
diff --git a/cppcache/src/ServerLocation.hpp b/cppcache/src/ServerLocation.hpp
index a0ce231..91cd670 100644
--- a/cppcache/src/ServerLocation.hpp
+++ b/cppcache/src/ServerLocation.hpp
@@ -89,7 +89,7 @@ class APACHE_GEODE_EXPORT ServerLocation
   }
 
   void printInfo() {
-    LOGDEBUG(" Got Host %s, and port %d", getServerName().c_str(), m_port);
+    LOGDEBUG(" Got Host \"%s\", and port %d", getServerName().c_str(), m_port);
   }
 
   bool operator<(const ServerLocation rhs) const {
diff --git a/cppcache/src/TcpSslConn.cpp b/cppcache/src/TcpSslConn.cpp
index 0ad9b91..f69d5b0 100644
--- a/cppcache/src/TcpSslConn.cpp
+++ b/cppcache/src/TcpSslConn.cpp
@@ -128,6 +128,10 @@ void TcpSslConn::init(const std::string& pubkeyfile,
        << socket_.remote_endpoint();
     LOGINFO(ss.str());
 
+    ss.clear();
+    ss << "SNI hostname: " << sniHostname;
+    LOGINFO(ss.str());
+
     socket_stream_ = std::move(stream);
   } catch (const boost::exception& ex) {
     // error handling
@@ -143,7 +147,7 @@ TcpSslConn::~TcpSslConn() {
   LOGFINE(ss.str());
 }
 
-size_t TcpSslConn::receive(char *buff, const size_t len,
+size_t TcpSslConn::receive(char* buff, const size_t len,
                            std::chrono::milliseconds) {
   auto start = std::chrono::system_clock::now();
 
@@ -181,7 +185,7 @@ size_t TcpSslConn::receive(char *buff, const size_t len,
                            });
 }
 
-size_t TcpSslConn::send(const char *buff, const size_t len,
+size_t TcpSslConn::send(const char* buff, const size_t len,
                         std::chrono::milliseconds) {
   return boost::asio::write(*socket_stream_, boost::asio::buffer(buff, len));
 }


Mime
View raw message