From 60254f81d26c37339428162d8789f74dfb27f9d2 Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Fri, 18 Jul 2014 19:28:10 +0000 Subject: QPID-4947: Injecting derived host address failed to strip IPv6 [] decoration git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1611776 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'qpid/cpp') diff --git a/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp b/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp index 75cca29b02..0e780a95bc 100644 --- a/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp +++ b/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp @@ -106,7 +106,7 @@ bool ConnectionCounter::countConnectionLH( } else { theMap[theName] = count = 1; } - if (enforceLimit) { + if (enforceLimit) { result = count <= theLimit; } if (emitLog) { @@ -230,7 +230,7 @@ bool ConnectionCounter::approveConnection( // // TODO: The global check could be run way back in AsynchIO where // disapproval would mean that the socket is not accepted. Or - // it may be accepted and closed right away without running any + // it may be accepted and closed right away without running any // protocol and creating the connection churn that gets here. // sys::SocketAddress sa(hostName, ""); @@ -354,7 +354,12 @@ std::string ConnectionCounter::getClientHost(const std::string mgmtId) size_t colon = mgmtId.find_last_of(':'); if (std::string::npos != colon) { // trailing colon found - return mgmtId.substr(hyphen+1, colon - hyphen - 1); + std::string tmp = mgmtId.substr(hyphen+1, colon - hyphen - 1); + // undecorate ipv6 + if (tmp.length() >= 3 && tmp.find("[") == 0 && tmp.rfind("]") == tmp.length()-1) + tmp = tmp.substr(1, tmp.length()-2); + return tmp; + } else { // colon not found - use everything after hyphen return mgmtId.substr(hyphen+1); -- cgit v1.2.1