From a34963a7a997313237fdd35936e24f8ad4de8ae2 Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Wed, 21 Sep 2022 14:00:49 +0200 Subject: [PATCH] rec: Remove the now unused parseService[4|6] and ServiceTuple --- pdns/misc.cc | 45 -------------------------------------------- pdns/misc.hh | 7 ------- pdns/test-misc_hh.cc | 11 +---------- 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index f06519d7f6..66dbb497db 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -310,51 +310,6 @@ bool stripDomainSuffix(string *qname, const string &domain) return true; } -static void parseService4(const string& descr, ServiceTuple& st) -{ - vector parts; - stringtok(parts, descr, ":"); - if (parts.empty()) { - throw PDNSException("Unable to parse '" + descr + "' as a service"); - } - st.host = parts[0]; - if (parts.size() > 1) { - pdns::checked_stoi_into(st.port, parts[1]); - } -} - -static void parseService6(const string& descr, ServiceTuple& st) -{ - string::size_type pos = descr.find(']'); - if (pos == string::npos) { - throw PDNSException("Unable to parse '" + descr + "' as an IPv6 service"); - } - - st.host = descr.substr(1, pos - 1); - if (pos + 2 < descr.length()) { - pdns::checked_stoi_into(st.port, descr.substr(pos + 2)); - } -} - -void parseService(const string &descr, ServiceTuple &st) -{ - if(descr.empty()) - throw PDNSException("Unable to parse '"+descr+"' as a service"); - - vector parts; - stringtok(parts, descr, ":"); - - if(descr[0]=='[') { - parseService6(descr, st); - } - else if(descr[0]==':' || parts.size() > 2 || descr.find("::") != string::npos) { - st.host=descr; - } - else { - parseService4(descr, st); - } -} - // returns -1 in case if error, 0 if no data is available, 1 if there is. In the first two cases, errno is set int waitForData(int fd, int seconds, int useconds) { diff --git a/pdns/misc.hh b/pdns/misc.hh index f367a94ade..0f43936971 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -84,13 +84,6 @@ DNSName getTSIGAlgoName(TSIGHashEnum& algoEnum); int logFacilityToLOG(unsigned int facility); -struct ServiceTuple -{ - string host; - uint16_t port; -}; -void parseService(const string &descr, ServiceTuple &st); - template void stringtok (Container &container, string const &in, diff --git a/pdns/test-misc_hh.cc b/pdns/test-misc_hh.cc index 248ef8d611..3dd8f9c093 100644 --- a/pdns/test-misc_hh.cc +++ b/pdns/test-misc_hh.cc @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(test_endianness) { uint32_t i = 1; #if BYTE_ORDER == BIG_ENDIAN BOOST_CHECK_EQUAL(i, htonl(i)); -#elif BYTE_ORDER == LITTLE_ENDIAN +#elif BYTE_ORDER == LITTLE_ENDIAN uint32_t j=0x01000000; BOOST_CHECK_EQUAL(i, ntohl(j)); #else @@ -135,15 +135,6 @@ BOOST_AUTO_TEST_CASE(test_endianness) { #endif } -BOOST_AUTO_TEST_CASE(test_parseService) { - ServiceTuple tp; - parseService("smtp.powerdns.com:25", tp); - BOOST_CHECK_EQUAL(tp.host, "smtp.powerdns.com"); - BOOST_CHECK_EQUAL(tp.port, 25); - parseService("smtp.powerdns.com", tp); - BOOST_CHECK_EQUAL(tp.port, 25); -} - BOOST_AUTO_TEST_CASE(test_ternary) { int maxqps=1024; BOOST_CHECK_EQUAL(defTer(maxqps, 16384), maxqps); -- 2.47.2