summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2012-11-16 14:27:08 +0000
committerAndrew Stitcher <astitcher@apache.org>2012-11-16 14:27:08 +0000
commit9d277505a7640b1f03039009f5dd41c9a3678e5c (patch)
treefcaa5b1f56b557220a777454eda9d7736c5d0bcf
parent4f8712fd4dcd6edfd471f81f166b636e8b03f6e2 (diff)
downloadqpid-python-9d277505a7640b1f03039009f5dd41c9a3678e5c.tar.gz
NO-JIRA: Removed unused isLocalHost() code
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1410360 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/include/qpid/sys/SystemInfo.h6
-rwxr-xr-xqpid/cpp/src/qpid/sys/posix/SystemInfo.cpp36
-rw-r--r--qpid/cpp/src/tests/SystemInfo.cpp16
3 files changed, 0 insertions, 58 deletions
diff --git a/qpid/cpp/include/qpid/sys/SystemInfo.h b/qpid/cpp/include/qpid/sys/SystemInfo.h
index f1434a9a7c..7e5d372300 100644
--- a/qpid/cpp/include/qpid/sys/SystemInfo.h
+++ b/qpid/cpp/include/qpid/sys/SystemInfo.h
@@ -53,12 +53,6 @@ QPID_COMMON_EXTERN bool getLocalHostname (Address &address);
QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList);
/**
- * Return true if host names an address of the local host.
- *@param host host name or IP address.
- */
-QPID_COMMON_EXTERN bool isLocalHost(const std::string& host);
-
-/**
* Retrieve system identifiers and versions. This is information that can
* generally be retrieved via POSIX uname().
*
diff --git a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
index dea74b4ab0..0f29f511b1 100755
--- a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
@@ -21,7 +21,6 @@
#include "qpid/log/Statement.h"
#include "qpid/sys/SystemInfo.h"
#include "qpid/sys/posix/check.h"
-#include <set>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
@@ -122,41 +121,6 @@ void SystemInfo::getLocalIpAddresses (uint16_t port,
}
}
-namespace {
-struct AddrInfo {
- struct addrinfo* ptr;
- AddrInfo(const std::string& host) : ptr(0) {
- ::addrinfo hints;
- ::memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC; // Allow both IPv4 and IPv6
- if (::getaddrinfo(host.c_str(), NULL, &hints, &ptr) != 0)
- ptr = 0;
- }
- ~AddrInfo() { if (ptr) ::freeaddrinfo(ptr); }
-};
-}
-
-bool SystemInfo::isLocalHost(const std::string& host) {
- std::vector<Address> myAddrs;
- getLocalIpAddresses(0, myAddrs);
- std::set<string> localHosts;
- for (std::vector<Address>::const_iterator i = myAddrs.begin(); i != myAddrs.end(); ++i)
- localHosts.insert(i->host);
- // Resolve host
- AddrInfo ai(host);
- if (!ai.ptr) return false;
- for (struct addrinfo *res = ai.ptr; res != NULL; res = res->ai_next) {
- if (isLoopback(res->ai_addr)) return true;
- // Get string form of IP addr
- char addr[NI_MAXHOST] = "";
- int error = ::getnameinfo(res->ai_addr, res->ai_addrlen, addr, NI_MAXHOST, NULL, 0,
- NI_NUMERICHOST | NI_NUMERICSERV);
- if (error) return false;
- if (localHosts.find(addr) != localHosts.end()) return true;
- }
- return false;
-}
-
void SystemInfo::getSystemId (std::string &osName,
std::string &nodeName,
std::string &release,
diff --git a/qpid/cpp/src/tests/SystemInfo.cpp b/qpid/cpp/src/tests/SystemInfo.cpp
index 12d8d3dba8..34f1ac408e 100644
--- a/qpid/cpp/src/tests/SystemInfo.cpp
+++ b/qpid/cpp/src/tests/SystemInfo.cpp
@@ -31,22 +31,6 @@ namespace tests {
QPID_AUTO_TEST_SUITE(SystemInfoTestSuite)
-QPID_AUTO_TEST_CASE(TestIsLocalHost) {
- // Test that local hostname and addresses are considered local
- Address a;
- BOOST_ASSERT(SystemInfo::getLocalHostname(a));
- BOOST_ASSERT(SystemInfo::isLocalHost(a.host));
- std::vector<Address> addrs;
- SystemInfo::getLocalIpAddresses(0, addrs);
- for (std::vector<Address>::iterator i = addrs.begin(); i != addrs.end(); ++i)
- BOOST_ASSERT(SystemInfo::isLocalHost(i->host));
- // Check some non-local addresses
- BOOST_ASSERT(!SystemInfo::isLocalHost("123.4.5.6"));
- BOOST_ASSERT(!SystemInfo::isLocalHost("nosuchhost"));
- BOOST_ASSERT(SystemInfo::isLocalHost("127.0.0.1"));
- BOOST_ASSERT(SystemInfo::isLocalHost("::1"));
-}
-
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests