]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Remove the now unused parseService[4|6] and ServiceTuple
authorFred Morcos <fred.morcos@open-xchange.com>
Wed, 21 Sep 2022 12:00:49 +0000 (14:00 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 26 Sep 2022 08:43:03 +0000 (10:43 +0200)
pdns/misc.cc
pdns/misc.hh
pdns/test-misc_hh.cc

index f06519d7f67ed5bd3602b495401e41ac9e078c19..66dbb497db31881f44ad36cad25eae3820cff340 100644 (file)
@@ -310,51 +310,6 @@ bool stripDomainSuffix(string *qname, const string &domain)
   return true;
 }
 
-static void parseService4(const string& descr, ServiceTuple& st)
-{
-  vector<string> 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<string> 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)
 {
index f367a94adeae6515f4caba8aedb4fee77b17897b..0f439369715f86d2253b8cfb001ab35fedb97f64 100644 (file)
@@ -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<typename Container>
 void
 stringtok (Container &container, string const &in,
index 248ef8d611682630bbf144c898af3ca105a1a144..3dd8f9c0933b235abd75466cb15f20932f8c8334 100644 (file)
@@ -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);