From a01695e82cfbfa6e296c66879c1e41802d3ea413 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 22 May 2014 08:55:14 +0200 Subject: WIP make connect use GetSrvRecords --- apt-pkg/contrib/srvrec.cc | 14 ++++++++++++++ apt-pkg/contrib/srvrec.h | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc index 352a56970..c473192fc 100644 --- a/apt-pkg/contrib/srvrec.cc +++ b/apt-pkg/contrib/srvrec.cc @@ -8,15 +8,29 @@ /*}}}*/ #include +#include + #include #include #include #include +#include #include #include "srvrec.h" +bool GetSrvRecords(std::string host, int port, std::vector &Result) +{ + std::string target; + struct servent *s_ent = getservbyport(htons(port), "tcp"); + if (s_ent == NULL) + return false; + + strprintf(target, "_%s._tcp.%s", s_ent->s_name, host.c_str()); + return GetSrvRecords(target, Result); +} + bool GetSrvRecords(std::string name, std::vector &Result) { unsigned char answer[PACKETSZ]; diff --git a/apt-pkg/contrib/srvrec.h b/apt-pkg/contrib/srvrec.h index 78d238c46..fd71e697f 100644 --- a/apt-pkg/contrib/srvrec.h +++ b/apt-pkg/contrib/srvrec.h @@ -26,6 +26,12 @@ class SrvRec } }; +/** \brief Get SRV records from host/port (builds the query string internally) + */ bool GetSrvRecords(std::string name, std::vector &Result); +/** \brief Get SRV records for query string like: _http._tcp.example.com + */ +bool GetSrvRecords(std::string host, int port, std::vector &Result); + #endif -- cgit v1.2.3