Browse Source

don't try SRV requests based on IP addresses

IP addresses are by definition not a domain so in the best case the
requests will just fail; we can do better than that on our own.
tags/debian/1.7.0_alpha0ubuntu2
David Kalnischkies 3 years ago
parent
commit
5935ef0d21
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      apt-pkg/contrib/srvrec.cc

+ 10
- 0
apt-pkg/contrib/srvrec.cc View File

@@ -11,6 +11,7 @@
#include <netdb.h>

#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <resolv.h>
#include <time.h>
@@ -32,6 +33,15 @@ bool SrvRec::operator==(SrvRec const &other) const

bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result)
{
// try SRV only for hostnames, not for IP addresses
{
struct in_addr addr4;
struct in6_addr addr6;
if (inet_pton(AF_INET, host.c_str(), &addr4) == 1 ||
inet_pton(AF_INET6, host.c_str(), &addr6) == 1)
return true;
}

std::string target;
int res;
struct servent s_ent_buf;


Loading…
Cancel
Save