diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-05-22 08:55:14 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-05-22 08:55:14 +0200 |
commit | a01695e82cfbfa6e296c66879c1e41802d3ea413 (patch) | |
tree | 35e7c3453f4ff3031b8c557ee7080e700179d5c3 /apt-pkg/contrib/srvrec.cc | |
parent | 8194f97685b4af2bbf0cdbdc88fe5332ad147353 (diff) |
WIP make connect use GetSrvRecords
Diffstat (limited to 'apt-pkg/contrib/srvrec.cc')
-rw-r--r-- | apt-pkg/contrib/srvrec.cc | 14 |
1 files changed, 14 insertions, 0 deletions
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 <config.h> +#include <netdb.h> + #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> #include <algorithm> +#include <apt-pkg/strutl.h> #include <apt-pkg/error.h> #include "srvrec.h" +bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &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<SrvRec> &Result) { unsigned char answer[PACKETSZ]; |